was: Re: looking for MOP documentation

Michael Hudson mwh at python.net
Fri Sep 19 08:07:52 EDT 2003


Peter Hansen <peter at engcorp.com> writes:

> Alan Kennedy wrote:
> > 
> > Peter Hansen wrote:
> > > Key phrase: "Metaobject protocols are interfaces to the language
> > > that give users the ability to incrementally modify the language's
> > > behavior and implementation...".  Near as I can tell, part of the
> > > whole character of Python is that a user *cannot* do either of
> > > those things.
> > 
> > Hmm, does this rephrasing hold any truth?
> > 
> > "Metaclasses are interfaces to the python language
> > that give users the ability to incrementally modify the language's
> > behavior and implementation...".
> > 
> > Isn't modifying standard behaviour the whole purpose of metaclasses?
> 
> But it doesn't really modify the *language's* behaviour in the way 
> implied by a simplistic reading of the above phrase.  That is, the
> "obvious" interpretation is that syntax and grammar are being affected,
> not just the behaviour of one small slice of the language, specifically
> how classes behave.  In some languages the two things are not so
> separate, but in Python they seem to be.

Huh?  Common Lisp's MOP doesn't change the language on that level,
either.  Presented with a form 

(foo bar)

nothing the MOP can do can change the usual processing (check to see
if foo is a macro, if so expand, otherwise check if it's a function,
if so evaluate bar and call the function, otherwise signal error).

Of course, there's a sense in which Common Lisp just doesn't have much
syntax, but Python's hardly overloaded with it, either.  *The objects*
or to be more precise the *types* of objects themselves are what
determine really happens, and that's precisely the sort of thing
metaclasses let you play with.

Cheers,
mwh

-- 
  Lisp does badly because we refuse to lie.  When people ask us if 
  we can solve insoluble problems we say that we can't, and because 
  they expect us to lie to them, they find some other language
  where the truth is less respected.   -- Tim Bradshaw, comp.lang.lisp




More information about the Python-list mailing list