[E-Lang] Immutable map operations

Bill Frantz frantz@pwpconsult.com
Thu, 29 Mar 2001 10:47:29 -0800


At 10:56 AM -0800 3/28/01, Tyler Close wrote:
>The "<<" operator shifts another bit into the bit field / collection.
>The "<<" operator has also already been overloaded by C++ to mean
>"write". It therefore seems plausible that "<<" is the "add another
>element" operator.
>
>	? var q := [ 'a', 'b', 'c' ] toFIFO()
>	# value: [a, b, c]
>
>	? q <<= 'd'
>	# value: [a, b, c, d]
>
>Works well for maps too:
>
>	map <<= (key, value)
>
>">>" also seems plausible for "remove an element". The following would
>remove one element equivalent to the given (key, value) pair.
>
>	map >>= (key, value)
>
>I think the real crux of this choice is what you decide to do with the
>String+ operator. Does "+" append a single character?
>
>	str += 'a'
>
>Or:
>
>	str <<= 'a'
>
>Or:
>
>	str |= [ 'a' ]
>
>To my eyes, the first two seem acceptable, but the third is
>ridiculous.

ARRRGH!  I think for readability, just building a Perl module for
distributed capabilities may be the best choice.

I admit there is a tension in a command language, between allowing it to
become write-only to get terseness, but in a general purpose programming
language clarity to the reader should be primary.  Programs are written
once.  By comparison, people read them many times.  The first time is
usually when they are being debugged.  IMHO, making all the set/map
operations into operators is going too far, even for a command language.

C is bad enough, with it's sometimes, even after 10+ years of use,
surprising operator precedence hierarchy.  (I always have to look up the
ordering of shift and mask when I encounter them without parentheses.  The
order of & and --> and . can also produce some surprises.)

If we are going to deprecate the use of String+, why replace it with an
operator at all?


-------------------------------------------------------------------------
Bill Frantz       | Microsoft Outlook, the     | Periwinkle -- Consulting
(408)356-8506     | hacker's path to your      | 16345 Englewood Ave.
frantz@netcom.com | hard disk.                 | Los Gatos, CA 95032, USA