How about Smalltalk-2000?
Stefan Matthias Aust
sma at 3plus4.de
Wed Feb 16 23:34:05 UTC 2000
>Warren Postma wrote:
>> >How much further do you want? I'm serious - please explain, and you may
>> >find (as here) that what you want already exists.
>>
>> Well, what about these array operations:
>>
>> a[5] := 10 " obvious array syntax "
>> a[5][9] := 0 " multiple levels of arrays "
>> a[0:10] := 0 " initialize a slice "
>> a[5:10] := b[10:15] " slice "
>> a["key"] := Value " dictionary "
>
>Well, I am guessing you know that you could write these things in
Smalltalk as
>(by adding a Slice class, of course):
>
> a at: 5 put: 10
> (a at: 9) at: 5 put: 9
> (a slice: 1 to: 11) put: 0 "Smalltalk indexes start at 1"
> (a slice: 5 to: 10) put: (b slice: 10 to: 15)
> a at: 'key' put: value
Comparing these two sets of expression, I've to admit that I like the above
more. Jecel is right, that this syntax is not too difficult to add, even
if it uses the same square brackets as blocks.
A year ago or so, I posted the needed changes to the Parser to allow a[x]
:= y and friends. I didn't add support for slices, but I could imagine
another patch which would allow ":" (or ".." which I'd probably prefer) as
a valid binary operator and then you could also express a[1 : 10] := 42.
bye
--
Stefan Matthias Aust // Bevor wir fallen, fallen wir lieber auf.
More information about the Squeak-dev
mailing list
|