Side-effect free containers for E
Thu, 10 Aug 2000 08:48:49 -0400
> "Mark S. Miller" <firstname.lastname@example.org>:
> OTOH, I'm scared of having both
> container[key]= newValue
> container[key]:= newValue
> be legal in the same language with very different meanings.
I'm afraid that would be right up there with = vs == in C on the bug
parade. If you add the first you must eliminate the second. I haven't
been able to think if a syntax that bakes the distinction clear but
still follows (historically based) intuition. Perhaps it is ok to make
it a little jarring to discourage thoughtless use, for example
[key]container := newvalue
On the other hand [key]= seems very natural. However it does require
that [key] be an operator:
container [key]=newvalue --> container := container [key] newvalue
container [key] newvalue --> container with(key,newValue)
So [key] acts as a binary operator to produce a new collection, as an
right unary operator to extract a value, and as a left unary operator
to produce an "L-value".
A little messy I admit.