On Fri, Mar 09, 2007 at 06:19:49PM -0600, Collin Winter wrote: > >History and Implementation > >========================== > > > >Class decorators were originally proposed alongside function decorators > >in PEP318 [1]_ and were rejected by Guido [2]_ for lack of use cases. > >Two years later he saw a use case he liked and gave the go-ahead for a > >PEP and patch [3]_. > > I'd still prefer it if this use case -- which is so central to the PEP > -- were provided in the PEP itself.
I'll make that more clear. The use cas was factory registration right next to the class definition (as opposed to afterwards or through a metaclass). This is the example I use most frequently in the PEP. > >Grammar/Grammar is changed from > > > > funcdef: [decorators] 'def' NAME parameters ['->' test] ':' suite > > > >to > > > > decorated_thing: decorators (classdef | funcdef) > > funcdef: 'def' NAME parameters ['->' test] ':' suite > > > >"decorated_thing"s are premitted everywhere that funcdef and classdef > >are premitted. > > > >An alternate change to the grammar would be to make a 'decoratable_thing' > >which would include funcdefs and classdefs even if they had no decorators. > > Is it "decorated_thing" or "decoratable_thing"? The current production is 'decorated_thing' because it requires at least one decorator so it is definitely decorated. If there are zero or more decorators it would become 'decoratable_thing' as it would include the case where something could be decorated but isn't. Thanks, and I'll go typo hunting. -Jack _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
