Re: [Python-3000] Metaclasses in Py3K

2006-12-18 Thread Greg Ewing
Talin wrote: > Do you have a specific proposal as to how the information about the > ordering of definitions could be extracted? I'm assuming that there > would be an extra attribute that would return a list of keys in the > order that they were defined. An extra attribute or method would be o

Re: [Python-3000] Metaclasses in Py3K

2006-12-18 Thread Talin
Greg Ewing wrote: > Talin wrote: > >> Do you have a specific proposal as to how the information about the >> ordering of definitions could be extracted? I'm assuming that there >> would be an extra attribute that would return a list of keys in the >> order that they were defined. > > An extra

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Talin
Greg Ewing wrote: > The main use case for all this seems to be that > some metaclasses would like to know the order in > which attributes were defined. So here's an > alternative proposal: Leave the syntax the way it > is, and *always* use a specialised dict that > remembers the order of definition

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Ronald Oussoren
On 16 Dec, 2006, at 22:39, Steven Bethard wrote: The main issue for me is that I think that its important to distinguish between get/set operations that are done at class definition time, and get/set operations that are done later, after the class is created. Why? Can you explain your

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Steven Bethard
On 12/17/06, Josiah Carlson <[EMAIL PROTECTED]> wrote: > Say I have a metaclass X. Say that I've been using metaclass X since > Python 2.2 days. One day I hear that shortly after Py3k, __metaclass__ > is going away and I need to start using some other syntax (say the > metaclass= syntax for argum

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Josiah Carlson
(wasn't quite done with that last message, so I'll just update the parts where I wasn't finished) Josiah Carlson <[EMAIL PROTECTED]> wrote: > Talin <[EMAIL PROTECTED]> wrote: > > I don't see why any existing metaclasses would need to be re-written - > > see below. For people using the old synta

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Greg Ewing
A point in favour of the current syntax and semantics is that you can do things like class C: class __metaclass__(type): ... or even, if you're feeling particularly devious, class C: def __metaclass__(name, bases, namespace): ... An enhanced namespace dict would re

Re: [Python-3000] Metaclasses in Py3K

2006-12-17 Thread Josiah Carlson
Talin <[EMAIL PROTECTED]> wrote: > > > Josiah Carlson wrote: > > Maybe I'm strange, but I don't like the precreation/double calling > > semantic. It just seems...sloppy? It requires modification of all > > current metaclasses to update to the new metaclass= syntax, just to > > possibly support

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Phillip J. Eby
At 12:53 PM 12/17/2006 +1300, Greg Ewing wrote: >The main use case for all this seems to be that >some metaclasses would like to know the order in >which attributes were defined. So here's an >alternative proposal: Leave the syntax the way it >is, and *always* use a specialised dict that >remembers

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Josiah Carlson wrote: > Maybe I'm strange, but I don't like the precreation/double calling > semantic. It just seems...sloppy? It requires modification of all > current metaclasses to update to the new metaclass= syntax, just to > possibly support a single operation, which, according to the discu

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Greg Ewing
Josiah Carlson wrote: > That could be trivially extended to support a tuple syntax for handling > meta dictionary support... > > class Foo(A, B) is type, dict: > ... -1. You're mangling my lovely syntax -- it no longer makes any sense! -- Greg ___

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Greg Ewing
Talin wrote: > My personal feeling on this issue is that just because the "keyword=X" > syntax opens up other possibilities, doesn't mean we have to use them. Even if the syntax was never used for anything else, I still don't like it. Metaclasses are an elegant concept that deserves an equally el

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Steven Bethard wrote: >> The main issue for me is that I think that its important to distinguish >> between get/set operations that are done at class definition time, and >> get/set operations that are done later, after the class is created. > > Why? Can you explain your use case? Everything I'd

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Phillip J. Eby
At 12:38 PM 12/16/2006 -0800, Talin wrote: >Phillip J. Eby wrote: >>At 11:30 AM 12/16/2006 -0800, Talin wrote: >>>The general idea is to have the metaclass create a mapping object which >>>is used as the 'locals' dictionary for the suite following the class >>>statement. There would be some special

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Phillip J. Eby
At 02:39 PM 12/16/2006 -0700, Steven Bethard wrote: > > The main issue for me is that I think that its important to distinguish > > between get/set operations that are done at class definition time, and > > get/set operations that are done later, after the class is created. > >Why? Can you explain

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Josiah Carlson
Talin <[EMAIL PROTECTED]> wrote: > > Josiah Carlson wrote: > > Talin <[EMAIL PROTECTED]> wrote: > >> There's also Josiah Carlson's proposal which separates the 'metaclass' > >> function into two parts, the 'dict creation part' and the 'class > >> finishing part'. (I.e. type= and dict=.) I woul

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Steven Bethard
Phillip J. Eby wrote: > There's mine, where you simply create mcls(name, bases, {}) and then map > locals operations to get/set/delattr operations on the class. This > would presumably be done using a simple mapping proxy, but it would be a > built-in type rather than the user having to implement

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Phillip J. Eby wrote: > At 11:30 AM 12/16/2006 -0800, Talin wrote: >> The general idea is to have the metaclass create a mapping object which >> is used as the 'locals' dictionary for the suite following the class >> statement. There would be some special-named function of the metaclass, >> such as

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Josiah Carlson wrote: >> 2) What should the interface on the metaclass look like. >> >> The general idea is to have the metaclass create a mapping object which >> is used as the 'locals' dictionary for the suite following the class >> statement. There would be some special-named function of the

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Josiah Carlson wrote: > Talin <[EMAIL PROTECTED]> wrote: >> There's also Josiah Carlson's proposal which separates the 'metaclass' >> function into two parts, the 'dict creation part' and the 'class >> finishing part'. (I.e. type= and dict=.) I would rather see them >> unified, as it makes the

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Phillip J. Eby
At 11:30 AM 12/16/2006 -0800, Talin wrote: >The general idea is to have the metaclass create a mapping object which >is used as the 'locals' dictionary for the suite following the class >statement. There would be some special-named function of the metaclass, >such as '__metadict__', which would con

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Josiah Carlson
Talin <[EMAIL PROTECTED]> wrote: [snip] > The main controversies are: Controversy is perhaps overstating it. There was disagreement. But it wasn't 300 posts and no names were called (that I can remember). > 1) How generalized the syntax should be. > > Several people, upon seeing your suggesti

Re: [Python-3000] Metaclasses in Py3K

2006-12-16 Thread Talin
Guido van Rossum wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. This is easier > when the metaclass is given in the class header, e.g. by way of a base > class, or through the default metaclass. Although the defa

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Greg Ewing
Phillip J. Eby wrote: > At 11:07 AM 12/12/2006 -0800, Thomas Wouters wrote: > >>I do wonder why classes don't use fast locals, though. Probably because (a) class creation is rarely a speed bottleneck in any program, and (b) by using a dict you end up with it already in the right form for passing

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Phillip J. Eby
At 11:07 AM 12/12/2006 -0800, Thomas Wouters wrote: >I do wonder why classes don't use fast locals, though. Because fast locals were an optimization added for functions. Before that, there was no such thing as fast locals: everything used dictionaries. >Building the locals dict from the fast l

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Thomas Wouters
On 12/12/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: At 10:11 AM 12/12/2006 -0800, Thomas Wouters wrote: >On 12/12/06, Jim Jewett ><[EMAIL PROTECTED]> wrote: >>On 12/8/06, Guido van Rossum <[EMAIL PROTECTED]> >>wrote: >> > I've been thinkin

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Phillip J. Eby
At 10:11 AM 12/12/2006 -0800, Thomas Wouters wrote: >On 12/12/06, Jim Jewett ><[EMAIL PROTECTED]> wrote: >>On 12/8/06, Guido van Rossum <[EMAIL PROTECTED]> >>wrote: >> > I've been thinking about this too, and I think it's reasonable to let >>

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Thomas Wouters
On 12/12/06, Jim Jewett <[EMAIL PROTECTED]> wrote: On 12/8/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. I do wonder about this though: will it require a particular

Re: [Python-3000] Metaclasses in Py3K

2006-12-12 Thread Jim Jewett
On 12/8/06, Guido van Rossum <[EMAIL PROTECTED]> wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. Is this something that could be done in 2.6, so long as the metaclass does happen to be set before the class statem

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Greg Ewing
Josiah Carlson wrote: > class FooClass(X, Y, implements=sequence): No, no, no, no, no. This is just the sort of thing I'm afraid of. "Implements equals" is an abomination against the English language. -- Greg ___ Python-3000 mailing list Python-30

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Greg Ewing
Calvin Spealman wrote: > The obvious problem with a metaclass specific syntax is that it doesnt > allow for other things. Please, let's not hypergeneralise. I would hate to see the class header get cluttered up with unbounded quantities of extra stuff. -- Greg ___

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Michel Pelletier
> From: Greg Ewing <[EMAIL PROTECTED]> > How about > >class C(B1, B2) is M: > ... +1 -Michel PS Please excuse me for my last email's digest subject. ___ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinf

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Phillip J. Eby
At 09:01 PM 12/9/2006 +0100, Ronald Oussoren wrote: >On Dec 9, 2006, at 2:17 AM, Phillip J. Eby wrote: > > The principal hurdle that would need to be overcome to do this, is > > that you > > can't change a builtin type's __class__ currently: > >Another hurdle is that you can add slots the the type

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Ronald Oussoren
On Dec 9, 2006, at 2:17 AM, Phillip J. Eby wrote: > At 01:20 PM 12/9/2006 +1300, Greg Ewing wrote: >> Talin wrote: >>> In other words, the >>> __metaclass__ statement would have a side-effect of replacing the >>> locals() dict with a mapping object supplied by the metaclass. >> >> __metaclass__ i

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Josiah Carlson
"Calvin Spealman" <[EMAIL PROTECTED]> wrote: > The obvious problem with a metaclass specific syntax is that it doesnt > allow for other things. Adding keyword options to class declarations > means you could do things beyond just metaclasses, such as interfaces, > if that happens. Right, but as is

Re: [Python-3000] Metaclasses in Py3K

2006-12-09 Thread Calvin Spealman
On 12/9/06, Greg Ewing <[EMAIL PROTECTED]> wrote: > > At 08:53 AM 12/8/2006 -0600, Guido van Rossum wrote: > > > >>I've been thinking about this too, and I think it's reasonable to let > >>the metaclass provide the dict to be used as locals. > > > > [snip] > > > >>class C(B1, B2, metaclass=Foo): >

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Greg Ewing
> At 08:53 AM 12/8/2006 -0600, Guido van Rossum wrote: > >>I've been thinking about this too, and I think it's reasonable to let >>the metaclass provide the dict to be used as locals. > > [snip] > >>class C(B1, B2, metaclass=Foo): If there's to be a special syntax for this, I don't think it sho

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Phillip J. Eby
At 01:20 PM 12/9/2006 +1300, Greg Ewing wrote: >Talin wrote: > > In other words, the > > __metaclass__ statement would have a side-effect of replacing the > > locals() dict with a mapping object supplied by the metaclass. > >__metaclass__ isn't a statement, it's just an >attribute that is interp

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Greg Ewing
Talin wrote: > In other words, the > __metaclass__ statement would have a side-effect of replacing the > locals() dict with a mapping object supplied by the metaclass. __metaclass__ isn't a statement, it's just an attribute that is interpreted in a special way *after* the class namespace has be

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Steven Bethard
At 08:53 AM 12/8/2006 -0600, Guido van Rossum wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. [snip] > class C(B1, B2, metaclass=Foo): >... On 12/8/06, Phillip J. Eby <[EMAIL PROTECTED]> wrote: > I definitely

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Thomas Heller
Talin schrieb: > Guido van Rossum wrote: >> I've been thinking about this too, and I think it's reasonable to let >> the metaclass provide the dict to be used as locals. This is easier >> when the metaclass is given in the class header, e.g. by way of a base >> class, or through the default metacla

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Talin
Guido van Rossum wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. This is easier > when the metaclass is given in the class header, e.g. by way of a base > class, or through the default metaclass. Although the defa

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Phillip J. Eby
At 08:53 AM 12/8/2006 -0600, Guido van Rossum wrote: >I've been thinking about this too, and I think it's reasonable to let >the metaclass provide the dict to be used as locals. This is easier >when the metaclass is given in the class header, e.g. by way of a base >class, or through the default met

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Talin
How about this: Email responses/ideas to me directly, I'll summarize them and post the result. Guido van Rossum wrote: > I've been thinking about this too, and I think it's reasonable to let > the metaclass provide the dict to be used as locals. This is easier > when the metaclass is given in the

Re: [Python-3000] Metaclasses in Py3K

2006-12-08 Thread Guido van Rossum
I've been thinking about this too, and I think it's reasonable to let the metaclass provide the dict to be used as locals. This is easier when the metaclass is given in the class header, e.g. by way of a base class, or through the default metaclass. Although the default default metaclass could of c

[Python-3000] Metaclasses in Py3K

2006-12-08 Thread Talin
I'd like to see metaclasses have additional capabilities in Py3K, and one thing I'd like is for metaclasses to be able to have access to the order of declarations within a class. If I understand correctly, in the current Python a class definition is essentially a suite with ordinary local varia