If Scheme is so good why MIT drops it?
Hendrik van Rooyen
hendrik at microcorp.co.za
Fri Jul 31 10:18:15 CEST 2009
On Thursday 30 July 2009 03:09:14 greg wrote:
> Hendrik van Rooyen wrote:
> > And if code is data, where is Pythons ALTER statement?
> class Duck:
> def quack(self):
> print "Quack!"
> def moo():
> print "Moo!"
> def ALTER(obj, name, TO_PROCEED_TO):
> setattr(obj, name, TO_PROCEED_TO)
> d = Duck()
> ALTER(d, 'quack', TO_PROCEED_TO = moo)
Nice, and I really appreciate the Duck,
but (there is always a but):
1) That is a function, not a statement.
2) The original changed a jump target address from
one address to another, and did not need the
heavy machinery of object oriented code.
So what you are doing is not quite the same.
It is actually not really needed in python, as
one can pass functions around, so that you can
call different things instead of jumping to them:
thing_to_call = moo
Does the equivalent without user level OO.
The original ALTER statement found use in building
fast state machines, where the next thing to do was
set up by the current state. In python one simply returns
the next state.
The equivalent python code is easier to read as it is
obvious what is happening - The COBOL source was
more obscure, as any jump could have been altered,
and you could not see that until you have read further
on in the program, where the ALTER statement was.
More information about the Python-list