# [E-Lang] Immutable map operations

Tyler Close tclose@oilspace.com
Thu, 29 Mar 2001 09:01:31 +0100

```MarkM wrote:
> >Works well for maps too:
> >
> >        map <<= (key, value)
>
> Interesting.  I think I like it.
>
>
> >">>" also seems plausible for "remove an element". The
> following would
> >remove one element equivalent to the given (key, value) pair.
> >
> >        map >>= (key, value)
>
> Less plausible, as a normal "without" would only provide
> ">>" to this fact yields even worse answers.

A normal without() would be:

map >>= key

and would mean "remove one element with a key equivalent to the given
key". I don't see how this is any "worse" than the "insert" syntax.
The operand to integer>> says what to "shift out", the map>> is
similarly told what to "shift out".

> >Or:
> >
> >        str <<= 'a'
> >
> >Or:
> >
> >        str |= [ 'a' ]
> >
> >To my eyes, the first two seem acceptable, but the third is
> >ridiculous.
>
> Could you explain why?  (Even if you can't, your reaction
> is still valuable
> input of course.)  In any case, even if we adopt your "<<"
> proposal, the
> second would still work by implication from our other choices.

Its the extra set of brackets that bother me.

All I wanted to do was add a single element to the collection. This
should be the easiest operation of all. The "| []" syntax makes me
feel like the language is asking me to jump through some extra hoops
just for the sake of some supposed compatibility with the "|"
operator.

The "| []" operator also reads like I am creating a new set and
computing the union. That may very well be a compatible interpretation
of the operation, but it's not the one I am thinking about when I want
to insert a single element.

The combination of two operators "|" and "[]" suggest that there are
two operations being done on this line of code and neither of them
immediately seem to have anything to do with "insert a single
element".

I am confused as to what the following would expand to:

str |= [ 'a', 'b' ]

expands to:

str := str op__with('a', 'b')

or:

str := str op_or( [a, b] )

The latter would append the characters 'a' and 'b' to the string. What
would the former do? And yet, the former is the normal expansion of
the "| []" operator.

Tyler

```