From: Johan Hidding <johannes.hidding@gmail.com>
To: Panicz Maciej Godek <godek.maciek@gmail.com>
Cc: "Ludovic Courtès" <ludo@gnu.org>, guile-user@gnu.org
Subject: Re: Reader syntax for accessing arrays
Date: Wed, 24 Aug 2011 21:52:48 +0200 [thread overview]
Message-ID: <CAEz5FLb_ekgs3RK7qCT5uYjVp6P1WczPgE1mTcwgbb+wtTdM=g@mail.gmail.com> (raw)
In-Reply-To: <CAMFYt2bFGUvMj2nn5XruvRpAYHkX2j-Y-jY-cit=ZQ5nOdY2Lg@mail.gmail.com>
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 <godek.maciek@gmail.com>:
> Hello,
>
>>>> 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)
>>
>> You could even write macros for this. I would actually find it more
>> elegant than additional syntax.
>
> The *=! 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 'slot)
>
> 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.
>
>
next prev parent reply other threads:[~2011-08-24 19:52 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
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 [this message]
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='CAEz5FLb_ekgs3RK7qCT5uYjVp6P1WczPgE1mTcwgbb+wtTdM=g@mail.gmail.com' \
--to=johannes.hidding@gmail.com \
--cc=godek.maciek@gmail.com \
--cc=guile-user@gnu.org \
--cc=ludo@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).