Python compilers?
Jacek Generowicz
jacek.generowicz at cern.ch
Mon May 24 08:32:38 EDT 2004
Paul Rubin <http://phr.cx@NOSPAM.invalid> writes:
> Carl Banks <imbosol at aerojockey.invalid> writes:
> > I don't follow you. In what way is Python dynamic that Lisp isn't?
>
>
> >>> class foo:
> ... def bar(self, x):
> ... return x*x
> ...
> >>> a = foo()
> >>> a.bar(3)
> 9
> >>> a.bar = lambda x: x*x*x
> >>> a.bar(3)
> 27
> >>>
I'm afraid you'll have to try harder.
[1]> (defclass foo () ())
#<STANDARD-CLASS FOO>
[2]> (defmethod bar ((foo foo) x)
(* x x))
#<STANDARD-METHOD (#<STANDARD-CLASS FOO> #<BUILT-IN-CLASS T>)>
[3]> (defparameter a (make-instance 'foo))
A
[4]> (bar a 3)
9
[5]> (defmethod bar ((self (eql a)) x)
(* x x x))
#<STANDARD-METHOD ((EQL #<FOO #x203185F9>) #<BUILT-IN-CLASS T>)>
[6]> (bar a 3)
27
More information about the Python-list
mailing list