RFC -- HYGIENIC MACROS IN PYTHON

Courageous jkraska at san.rr.com
Tue Feb 5 01:29:44 EST 2002


>Looking at what you proposed, I'm not sure I understand what differentiates
>your "lingo" from a common function.  A function seems to be everything
>you've defined for lingo.  Is there some problem that using function calls
>can't solve?

Did you read the examples? Python doesn't have a do/while form. Or a switch
form (not shown). Lingos are intended to address to demands of programmers,
many of whom currently use lisp, who have a need to generate domain-specific
languages as dialects of the language they are using. While lingos aren't
complete, they are a start. This is a specialized application and not really
at all Pythonic. But that's a different issue. I digress.

You are confused. Consider the following:

>>> def f(i): i = 3

>>> i = 4
>>> f(i)
>>> i
4
>>> 

Using a lingo, i would be 3.

Return or yield in a lingo might or might not (undecided) cause the
caller to return or yield. Haven't thought that through yet. If it
were a macro, it clearly would.

One possible way to get proper behavior while using a macro is to
open a first class lexical scope in the definition and then otherwise
insert the entire AST of the defining body into the caller. This would
work correctly, I think, and possibly is the proper implementation. TBD.

C//




More information about the Python-list mailing list