merits of Lisp vs Python

greg greg at cosc.canterbury.ac.nz
Sat Dec 16 02:21:41 EST 2006


Ken Tilton wrote:

> I think your brain is stuck on flaming.

Sorry, I didn't mean to come across as flaming, far
from it. I'll take a deep breath before posting from
now on, I promise. :-)

> I did explain the last little fun bit (where reverse code miraculously 
> got a case-specific "signed-value" parameter bound to exactly the right 
> bit of math structure).

I didn't mention that because it was addressed by
another poster. The signature of the user's reverse
function can be made extremely flexible if you have
the foresight to define it as something like

    def reverse(resx, opnd, **kwds):
      ...

Then you can later change it to

   def reverse(resx, opnd, signed_value, **kwds):
      ...

and any existing reverse functions will just absorb
and ignore the extra argument.

However, rather than add an ever-increasing number
of arguments to the signature, I think I would do it
a different way: pass a single object with attributes.
For the want of a better name, let's call it "env"
for "environment". The signature is then

   def reverse(env):
      ...

and the body can refer to env.resx, env.opnd,
env.signed_value, or whatever else is required.

If this still doesn't cover the requirements, please
explain and I'll try to adapt it accordingly.

--
Greg



More information about the Python-list mailing list