Side-effect free containers for E
Mark S. Miller
markm@caplet.com
Mon, 14 Aug 2000 23:00:18 -0700
At 05:46 AM 8/10/00 , Tyler Close wrote:
>For associative containers:
>
> container += (key, value)
>
>expands to
>
> container := container + (key, value)
>
>expands to
>
> container := container with(key, value)
>
>I think this is a clean and accurate syntax.
You raise two sets of issues here. The first has to do with our original
discussion -- how shall containers behave and what syntax shall we use to
manipulate them?
The second you raise implicitly: Since our overloaded operators are merely
syntactic sugar for message names, why not allow the right hand argument of
an overloaded operator to be an n-ary argument list? After all, if the right
argument is a non-parenthesized expression, that already means the same
thing as a 1-ary argument list. Interesting. I think this generalization
is simple and seems simple. I just tried it, and it does result in an
unambiguous grammar. From my latest Elmer session:
? e`x += (2, 3)`
# value: e`x := x add(2, 3)`
? e` 2 + ()`
# value: e`2 add`
And checking an edge condition:
? e`x ** y %% z`
# value: e`x modPow(y, z)`
? e`x ** (y, z) %% w`
# value: e`x pow(y, z) mod(w)`
? e`x ** y %% (z, w)`
# value: e`x pow(y) mod(z, w)`
Only the double 1-ary case of ** combined with %% gets optimized into modPow.
Does anyone object to this generalization of the syntax rules?
Cheers,
--MarkM