For Kenny Tilton: Why do I need macros revisited.

Michele Simionato mis6 at pitt.edu
Sun Aug 24 05:31:32 EDT 2003


Kenny Tilton <ktilton at nyc.rr.com> wrote in message news:<3F47BDCA.3070001 at nyc.rr.com>...
> A few months back I started on a PyCells project, and of course was 
> having great fun down at the metaclass level. It was a little daunting 
> compared to the Lisp MOP, which just takes the same concepts of calls 
> and instance and does a conceptual-shift-up (new machine language 
> instruction?) so a class is now an instance (of a metaclass, which is 
> just another class really--the "meta" is only to keep one's head 
> straight). Python might be viewed as easier because it jumps over to 
> using internals such as that __dict__ thing (sorry if that is wrong, it 
> has been a while and I only played for a few weeks), so it there is none 
> of that class-being-an-instance confusion. Fun stuff, either way.


I don't follow you. In Python it is just the same, a class is just an
instance of a metaclass, a metaclass is just an instance of a meta-meta
class, etc. Metaclasses are classes, their simply have a different
type.__new__ method than object.__new__ so the instantiation syntax
looks a bit different.

> The CLOS MOP is a better playground, but Python has 
> a clear win in that there is only one Python. If I really need the MOP 
> for a project, I just pick a CL which exposes it. If I want to deliver a 
> package any lispnik can use, I better not use the MOP.


Hear, hear, people who say CL is more standard than Python!
> (How do you like that? 
> Multiple inheritance of metaclasses! <g>) 

I need more multiple inheritance for metaclasses than for classes.
You maybe interested in this recipe of mine:

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204197

> Even if CLOS metaclasses were standard, kind of in the spirit of some of 
> this thread, I think I would like to avoid doing Cells by tinkering with 
> the object model. A hack that kinda disappears at run time (the macros 
> expand into vanilla CL) is probably going to play better with other 
> hacks, including not breaking optimizations. ANd it may be a Message 
>  From God(tm) that Cells internals got simpler when I ripped out the 
> metaclass thing.
> 
As always, the most abstract solution is not necessarely the best 
solution.

Michele Simionato, Ph. D.
MicheleSimionato at libero.it
http://www.phyast.pitt.edu/~micheles
--- Currently looking for a job ---




More information about the Python-list mailing list