[E-Lang] Operators #4: Indexing!

Mark S. Miller markm@caplet.com
Fri, 06 Apr 2001 19:39:00 -0700


The relevant parts of Python page 
http://www.python.org/doc/current/ref/sequence-types.html would have us expand

    thing[key]

to

    thing op__getitem(key)

and expand

    thing[key] := value

to

    thing op__setitem(key, value)

There are two controversies here:

* These names are a violation of our midCap convention, and presumably 
Python's as well.  Why oh why didn't Python call these "__getItem__" and 
"__setItem"?  Given that they didn't, how should we cope?  I propose that we 
adopt the names without caps, and blame Python for the non-uniformity.

* Assuming we succeed at the current exercise, E's own core collection types 
will be immutable, and so will not respond to op__setitem.  However, the 
Java mutable collection types will continue to be accessible at least from 
<unsafe:...> in E-on-Java, and will be explained first to Java programmers 
as training wheels, since they're already familiar with them.  So I propose 
that we keep both expansions in the language.  Our users will then also be 
free to create their own mutable collection types that respond to 
op__setitem, and thereby benefit from the above shorthand.

        Cheers,
        --MarkM