[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Reader syntax for accessing arrays
From: |
Johan Hidding |
Subject: |
Re: Reader syntax for accessing arrays |
Date: |
Wed, 24 Aug 2011 21:52:48 +0200 |
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 <address@hidden>:
> 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.
>
>