merits of Lisp vs Python

Pillsy pillsbury at gmail.com
Mon Dec 11 21:13:39 EST 2006


Piotr wrote:

> Paul Rubin wrote:
[...]
> > Well, there's some similar way to look up elements in a Lisp
> > hashtable, but I've forgotten the keyword for it (oops, cognitive
> > inefficiency, having to remember separately.)

FWIW, the command is GETHASH. The situation in CL is actually even
worse than just having different names for these functions, since some
functions put the index as the first argument (GETHASH, NTH) and others
put it as the second argument (AREF, ELT). You can at least hide this
archaic nonsense away by defining methods for a generic function if it
bugs you.

> > Python uses the same syntax for both.

> That's true, Lisp would benefit from _standard_ homogenuous polymorphic
> accessor functions to list-like objects and/or low-level (macro-like)
> syntactic sugar.  Yes, you can easily make (a i) act like (aref a i)
> but it is not done by default.  Legacy reasons?

Well, it's not such a hot idea in a Lisp-2, since you'll often have a
variable named, say, LIST, and then the meaning of (LIST 1) becomes
ambiguous.

In CL, you could do the implicit indexing with different braces,
though, like [a i] for (aref i); this is something I periodically
consider doing.

Cheers,
Pillsy




More information about the Python-list mailing list