python and macros (again) [Was: python3: 'where' keyword]

Steve Holden steve at holdenweb.com
Wed Jan 12 18:06:04 EST 2005


Paul Rubin wrote:

> michele.simionato at gmail.com writes:
> 
>>>I can't imagine how it could be worse than the learning curve of
>>>__metaclass__, which we already have.
>>
>>To me, learning macros *and their subtilities* was much more difficult
>>than learning metaclasses.
> 
> 
> I guess I've only used Lisp macros in pretty straightforward ways,
> that weren't hard to understand.  That's enough for anything I've
> needed.  But we don't hear much about __metaclass__ because almost
> nobody understands it.
> 
Paraphrasing Tim Peters, "if you don't definitely know that you need 
metaclasses then you almost certainly don't". The primary reason for the 
existence of metaclasses is as an implementation detail that allows 
basic Python types to be base classes for inheritance. Python could have 
hidden this mechanism, but the generally introspective nature of the 
language makes it sensible to expose the mechanism for (ab)use by 
knowledgeable users.
> 
>>Go to comp.lang.scheme and google for "macros and module system";
>>you will get everything you want to know and much more!
> 
> 
> OK, I might do this.
> 
Well I'd be interested to know what you find out, not being a Lisper myself.
> 
>>Well, I see this as a positive fact. If a syntax is contrived (such
>>as a ternary operator, for instance) it is better *not* to have it
>>than to have one hundred custom made syntaxes. At the end, we are
>>just talking about syntax sugar here, not about lack of
>>functionality.
> 
> 
> I think the idea is there would be some experimentation and then one of
> the versions would make it into the standard library.
> 
Erm, you'd put syntax into a library module? That would be in 
__future__, I take it?
> 
>>>[compiling Lisp to Python bytecode]
>>
>>This is a bizarre idea if you want to make Python run faster. It is
>>not so bizarre if what you want is to have access to Python from
>>Lisp/Scheme in the same sense Jython has access to Java.
> 
> 
> Why not just use a foreign function interface?

regards
  Steve
-- 
Steve Holden               http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/
Holden Web LLC      +1 703 861 4237  +1 800 494 3119



More information about the Python-list mailing list