Good Things About E

Ka-Ping Yee
Mon, 19 Oct 1998 01:25:11 -0700 (PDT)

The following thoughts have been in my mind about E for some
time and i'm sure they are obvious to everyone already, but i
thought i would just put them down here to solidify and verify
them.  I would really appreciate if someone just lets me know
if i've got the right picture here.

E objects are like lambda closures with methods.  They are just
like lambda, but instead of knowing how to do only one thing,
you can choose which of many actions they will dispatch to.  An
E "function" (object with just a run() method) is a lambda.

Each object remembers its binding scope, the scope in which it
was defined.

E doesn't have the particular feature of Python where you can
reach into an object and take out a method as a separate
function object, or where you can take a function and stick it
into an object as a method definition.

This sort of flexibility can still be achieved if the object
wishes to allow it by delegating specific messages to another
object (representing the function you wanted to put into the
method slot).

But the strictness which comes from knowing all the methods at
definition time: (a) means you can verify security by looking
at one short piece of code and (b) means the compiler can
optimize method calls knowing that they will never change.

Making the flexibility available this way makes it (a) explicit
when delegation is taking place and (b) causes this run-time
method call resolution to happen only in the specific cases
where the author makes it necessary (instead of all the time,
as in Python).

(For example, in Python the definition of the __getattr__
method call is fixed when a class is defined even though all
other methods can be freely removed and replaced like any other
object attributes.  This exception was necessary because the
__getattr__ method is called so often -- every time any
attribute (including a method) is looked up for the object --
that too much performance would be lost if the interpreter
were not able to cache the __getattr__ method in the class.)

When optional type information on the object is given in E
this would allow the compiler to turn a method call into a
straight jump with no lookup at all.  This could never happen
in Python even with the type information (except on immutable
objects like ints) because you still have to worry about the
possibility that someone might come along later and change
the method.

Am i making any sense?