unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Johan Hidding <johannes.hidding@gmail.com>
To: Panicz Maciej Godek <godek.maciek@gmail.com>
Cc: guile-user@gnu.org
Subject: Re: Reader syntax for accessing arrays
Date: Tue, 23 Aug 2011 10:10:05 +0200	[thread overview]
Message-ID: <CAEz5FLZbudHezzLDf29cKkziEKEbgJey8rpYPD3GKSnOpd+LPg@mail.gmail.com> (raw)
In-Reply-To: <CAMFYt2ZqK7ax7uU3os0c+Oe_gGFY0aiPsHoVdCc_Zu2Xe41GeQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]

Hi Maciej,
I've been thinking among the same lines. At the same time this syntax could
be used to access members of a 'struct' or 'class' object. It should be
relatively simple to write a small interpreter (or maybe a pre-compiler).
Otherwise you could make a wrapper around the array in the form of a
closure. In that case, your example could be written
(*=! (a i j) 2)
Cheers, Johan

2011/8/23 Panicz Maciej Godek <godek.maciek@gmail.com>

> Hi,
> I've noticed that one of the biggest inconveniences of lisp is a very
> clumsy way of accessing arrays.
> Having to write
> (array-set! a (* (array-ref a i j) 2) i j))
> seems to be unnecessarily prolix, for in C, language designed
> specifically to access arrays,
> the same operation could be written as
> a[i][j] *= 2;
>
> Indeed, LISP is intended for processing lists, but there are certain
> tasks where dealing with
> arrays is inevitable. So perhaps it would be a good idea to use square
> brackets, as it is
> done in C, to access arrays, so that
> [a i j]
> could be understood by the interpreter as
> (ref-array a i j)
> where ref-array is the appropriate getter with setter.
>
> Therefore I wonder how could this functionality be implemented in
> guile, or, preferably,
> in generic R^5RS. [I've heard that R^6RS makes no distinction between []
> and ()]
>
> Regards
> Maciek
>
>

[-- Attachment #2: Type: text/html, Size: 1735 bytes --]

  reply	other threads:[~2011-08-23  8:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-22 23:17 Reader syntax for accessing arrays Panicz Maciej Godek
2011-08-23  8:10 ` Johan Hidding [this message]
2011-08-23 18:03   ` Panicz Maciej Godek
2011-08-24 10:51     ` Ludovic Courtès
2011-08-24 18:45       ` Panicz Maciej Godek
2011-08-24 19:52         ` Johan Hidding
2011-08-26 21:02           ` Panicz Maciej Godek
2012-01-09 15:39 ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAEz5FLZbudHezzLDf29cKkziEKEbgJey8rpYPD3GKSnOpd+LPg@mail.gmail.com \
    --to=johannes.hidding@gmail.com \
    --cc=godek.maciek@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).