[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reader syntax for accessing arrays
From: |
Panicz Maciej Godek |
Subject: |
Re: Reader syntax for accessing arrays |
Date: |
Wed, 24 Aug 2011 20:45:46 +0200 |
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.