What's better about Ruby than Python?

Andrew Dalke adalke at mindspring.com
Thu Aug 21 13:00:44 EDT 2003


Kenny Tilton
> Lisp hashtables can key off any Lisp datum, but...

Bear with my non-existant Lisp knowledge

Suppose the code is modified.  How does the hash table
get modified to reflect the change?  Written in Python,
if I have

a = (1, 2, (3, [4, 5]))

I can't hash it because someone could come by later
and do

a[2][1].append(6)

so the hash computation and test for equality
will give different results.

> The next step would
> have been to determine when the closure had best re-execute the code
> body to see if the world had changed in interesting ways, but that is a
> big step and requires dependency tracking between cells.

Ahhh, so the Python code was comparable in power without
using macros?

> Once a Cell is told an input has changed, it re-runs its body to see if
> it comes up with a different result, in which case it caches that and
> tells other dependents to rethink their caches.

Err, or maybe not.  I don't see how this is done in the Lisp
code.  Still, such flexibility is available in Python without
recourse to macros.

> So what is shown in my example is fun but halfbaked. I was just trying
> to show how a macro could hide the plumbing of an interesting mechanism
> so the reader can focus on the essence.

Could the same code be written in Lisp using an approach
like I did for Python?  How would a non-macro solution look
like?  What's the advantage of the macro one over the non-macro
one?  Just performance?

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list