osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Commonly-used names in the Python standard library


Chris Angelico <rosuav at gmail.com>:

> On Fri, Feb 21, 2014 at 9:26 PM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> With #define. Nowhere near as elegant (flexible, hygienic) as in
>> Lisp, but used to create new syntax:
>
> That can't create new syntax, though. All it can do is create a thing
> that looks like a symbol or a function call and plonks a bit of code
> in at that point. That's all. It's more akin to creating a function
> that's able to work with blocks of unexecuted code.

Exactly! Lisp functions and macros (including special forms) are closely
related. The whole scheme (no pun intended) is so attractive because of
the S expression "supersyntax." A "while" macro is syntactically no
different from a "while" function. A macro is a "function" whose
automatic argument evaluation is disabled; the macro "function" gets the
ASTs of the arguments as input. A macro can always simulate a function
but not the other way round.

With the addition of macros, Python would become a (remote) Lisp
dialect. Defining macros would become more complicated because of
Python's more complex "supersyntax."


Marko