[E-Lang] Hydro & E: Update Syntax

Ralph Hartley hartley@aic.nrl.navy.mil
Thu, 22 Mar 2001 15:52:10 -0500


zooko@zooko.com wrote:

>  MarkM wrote:
> 
> 
>>     map := map with(key, newValue)
> 
> proposed syntactic shorthand:
> 
>>     map [key]= newValue
> 
Now that would be confusing. map[key] sure looks like an lvalue!

> 
>>     map += (key, newValue)
> 
If + is insert, not concatenate. Confilcts with

print "abc"+"def"

producing abcdef

> 
>>     map |= [key => newValue]
> 
Are there any similar uses of | ? I would think set1 |= set2 would put 
the union of set1 and set2 into set1 (set1 = set1 union set2) . | is 
often "or". For maps I would expect whatever the merge operation does. 
Then &= would replace a set with the intersection.

> 
>>     map := map <| [key => newValue]
> 
Couldn't figgure that one out, even knowing what it was suposed to mean!

> 
>>     map with= (key, newValue)
> 
I don't see any real problem with that one. Whatever the add_one_element 
operator is.

> FWIW, I personally would be happy with the syntax requiring the old and new map
> to be named twice, e.g.
> 
>     map := map with(key, newValue)

...

> Hm.  It does seem to me that any of the shorthand proposals would lead to
> newbie programmers thinking that they were doing a mutation and being unable to
> figure out why it didn't work.

I wouldn't realy expect that.

map with= (key, newValue)

is a fairly obvious extension of A op= B which is always exactly the 
same as A := A op B. (If it were not ALWAYS exactly the same, I would 
have a problem!)

I don't expect str += "abc" to change other uses of the string (in 
java), nor would I expect x=5; x+=1; to do anything to 5.  Also, I would 
expect 5 += 1 to be illigal in any reasonable language, not because it 
tries to change 5, but bexause it tries to assign a new value to it.

I'm hardly a newbie programmer, but I am very used to C and Java.

Ralph Hartley