From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Panicz Maciej Godek Newsgroups: gmane.lisp.guile.user Subject: Re: Reader syntax for accessing arrays Date: Wed, 24 Aug 2011 20:45:46 +0200 Message-ID: References: <87bovf5bg0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1314212125 24014 80.91.229.12 (24 Aug 2011 18:55:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 24 Aug 2011 18:55:25 +0000 (UTC) Cc: guile-user@gnu.org To: =?ISO-8859-1?Q?Ludovic_Court=E8s?= Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 24 20:55:21 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1QwIbc-0002p8-5d for guile-user@m.gmane.org; Wed, 24 Aug 2011 20:55:16 +0200 Original-Received: from localhost ([::1]:58850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwISr-0005Wg-3l for guile-user@m.gmane.org; Wed, 24 Aug 2011 14:46:13 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwISf-0005TT-PM for guile-user@gnu.org; Wed, 24 Aug 2011 14:46:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwISe-0006cJ-TW for guile-user@gnu.org; Wed, 24 Aug 2011 14:46:01 -0400 Original-Received: from mail-qy0-f176.google.com ([209.85.216.176]:41686) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwISe-0006bi-MW; Wed, 24 Aug 2011 14:46:00 -0400 Original-Received: by qyk7 with SMTP id 7so1274206qyk.0 for ; Wed, 24 Aug 2011 11:45:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=Blq8uWnRfI8YPoccfPAKhi7J23EwTUxKlCvgTbbeSZw=; b=XOhdHq1TD+Vs1Gvbzwqdt3o/N5V6O9h2Wl2ljrhmKlXoQEIn2Cv64mM3ka0XnZXsjQ ng+8XPXidjai32G+adjFKLDtIowUSE0+KpHISKrkFLq0xiZbFTUk8+ep+FyclYzGQbQw eqVqRbdegb896/4VBzpC/rmXBwardM7gaarm0= Original-Received: by 10.52.96.33 with SMTP id dp1mr5539794vdb.20.1314211546460; Wed, 24 Aug 2011 11:45:46 -0700 (PDT) Original-Received: by 10.220.194.136 with HTTP; Wed, 24 Aug 2011 11:45:46 -0700 (PDT) In-Reply-To: <87bovf5bg0.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.216.176 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8733 Archived-At: Hello, >>> Otherwise you could make a wrapper around the array in the form of a >>> closure. In that case, your example could be written >>> (*=3D! (a i j) 2) > > You could even write macros for this. =A0I would actually find it more > elegant than additional syntax. The *=3D! operator could be easily created using `define-syntax'. But that'= s not the issue. The most important part is array indexing (and -- as Johan suggests -- accessing object's members). I think it would be nice to write [a 5] instead of (array-ref a 5), and [o 'slot] instead of (slot-ref o 'slo= t) That would be a fairly simple extension of syntax, I suppose. I don't know how one could achieve this using macros. Of course, it's possible to wrap the arrays and objects around with closures, as Johan pointed out [and similarly to srfi-100 `define-lambda-object'], but this has some other disadvantages. Best regards M.