python hack of the day -- "listable" functions

Lars Marius Garshol larsga at ifi.uio.no
Sat May 15 14:29:36 EDT 1999


* William Tanksley
|
| Now, consider this.
| 
| x = o.verb(a,b,c)
| 
| You've created a language feature where the action of the verb depends not
| on the single object it's attached to, but on EACH of the parts of speech
| in its parameter list.
 
* Charles Hixson
| 
| I think that Common Lisp inheritance works like that.  Perhaps Dylan
| also, but if I remember correctly the Common Lisp version had this
| feature in a "more essential" form.

Common Lisp method dispatch (not inheritance) does indeed work exactly
like this, although it can dispatch on the type as well as the class
of parameters. The CL crowd calls this generic methods.

And, yes, I think Dylan copied this (along with lots of other CL
stuff).

| Truthfully, this might just have been a feature of Franz' Allegro
| Common Lisp, but I don't think so.

It's not, it's an integral feature of CLOS, the Common Lisp Object
System.

--Lars M.




More information about the Python-list mailing list