From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Johan Hidding Newsgroups: gmane.lisp.guile.user Subject: Re: Reader syntax for accessing arrays Date: Wed, 24 Aug 2011 21:52:48 +0200 Message-ID: References: <87bovf5bg0.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1314215596 14742 80.91.229.12 (24 Aug 2011 19:53:16 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 24 Aug 2011 19:53:16 +0000 (UTC) Cc: =?UTF-8?Q?Ludovic_Court=C3=A8s?= , guile-user@gnu.org To: Panicz Maciej Godek Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Wed Aug 24 21:53:09 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 1QwJVc-0008Bt-PZ for guile-user@m.gmane.org; Wed, 24 Aug 2011 21:53:08 +0200 Original-Received: from localhost ([::1]:44679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwJVc-0002bC-38 for guile-user@m.gmane.org; Wed, 24 Aug 2011 15:53:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:55985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwJVY-0002X4-SV for guile-user@gnu.org; Wed, 24 Aug 2011 15:53:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QwJVU-0006qr-Nn for guile-user@gnu.org; Wed, 24 Aug 2011 15:53:04 -0400 Original-Received: from mail-pz0-f44.google.com ([209.85.210.44]:48564) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QwJVU-0006pa-Dq; Wed, 24 Aug 2011 15:53:00 -0400 Original-Received: by pzk36 with SMTP id 36so1486768pzk.17 for ; Wed, 24 Aug 2011 12:52:48 -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=BTQcBqWaK7P4J1wVk3woToNTDhswzbaE5sUl+cRncxo=; b=Gzdo+yBrQXFPH8sX+lCTkYiIzwRI1J4HmcVe39CXR4UdIvCMq79HuonSnh7EJ+PN82 mSfhWYCEK/nbnX0VmoCgYFvfAxrJ2hT6QSCwgCHg8F1ids5k0Kppdn/NqQpxPq29yShM DV4R6gR5prxYN+uFnwoNuU7edXXDViQ39auPA= Original-Received: by 10.143.97.31 with SMTP id z31mr2857074wfl.391.1314215568590; Wed, 24 Aug 2011 12:52:48 -0700 (PDT) Original-Received: by 10.68.55.99 with HTTP; Wed, 24 Aug 2011 12:52:48 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.210.44 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:8734 Archived-At: Hi, I think it is a question of philosophy. The suggested [] syntax contains the scent of both infix notation (would [7 '* 6] work?) and work on arrays in stead of lists (also in the case of object member reference; the most straight forward implementation would be having a memory offset assigned to the member). Both concepts are foreign to the minimal nature of the scheme philosophy. To top it, getting both concepts into a rigidly defined syntax, would require a form of currying. The resulting language would be much more efficient for doing scientific/numerical work, but I don't know if it's really worth the trouble. Cheers, Johan 2011/8/24 Panicz Maciej Godek : > 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. =C2=A0I would actually find it mor= e >> elegant than additional syntax. > > The *=3D! operator could be easily created using `define-syntax'. But tha= t'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 writ= e > [a 5] instead of (array-ref a 5), and [o 'slot] instead of (slot-ref o 's= lot) > > 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. > >