Python syntax in Lisp and Scheme

Kaz Kylheku kaz at ashi.footprints.net
Mon Oct 13 17:00:50 EDT 2003


gregm at cs.uwa.edu.au wrote in message news:<blr1cq$bb1$1 at enyo.uwa.edu.au>...
> In comp.lang.functional Erann Gat <my-first-name.my-last-name at jpl.nasa.gov> wrote:
> : For example, imagine you want to be able to traverse a binary tree and do
> : an operation on all of its leaves.  In Lisp you can write a macro that
> : lets you write:
> : (doleaves (leaf tree) ...)
> : You can't do that in Python (or any other langauge).
> 
> My Lisp isn't good enough to answer this question from your code,
> but isn't that equivalent to the Haskell snippet: (I'm sure
> someone here is handy in both languages)
> 
> doleaves f (Leaf x)     = Leaf (f x)
> doleaves f (Branch l r) = Branch (doleaves f l) (doleaves f r)

You appear to be using macros here to define some entities. What if we
took away the syntax which lets you write the above combination of
symbols to achieve the associated meaning? By what means would you
give meaning to the = symbol or the syntax (Leaf x)?

Or give me a plausible argument to support the assertion that the =
operator is not a macro. If it's not a macro, then what is it, and how
can I make my own thing that resembles it?




More information about the Python-list mailing list