@decorator syntax is sugar, but for what exactly?
avner at skilldesign.com
Mon Aug 9 19:25:48 CEST 2004
Mark Bottjer wrote:
> I, personally, don't like the idea of overloading def in this way. To
> me, 'def' defines something that looks and acts like a function, just
> like 'class' defines something that looks and acts like a class, or
> 'while' defines something which looks and acts like a loop. AProperty is
> does not act like a function, so using def would be misleading.
Properties do not look like functions but are implemented as functions.
there is no requirement that a variable must hide behind a property, or
that it Must allow both read and write access.
> property a:
> def __init__( s, v):
> __set__( s, v)
Why property constructor?
> Taking this to the extreme, all existing statement types (class, def,
> print, del, etc.) could be recast as these generalized statements. We
> could even allow subclassing of existing statements to modify their
> behavior (for example, class_def subclassing def to make the new
> function a class method). Strong Kung-Fu indeed. Scary, but strong.
I recall reading somewhere That the Beta language allowed subclassing
> Obviously, creating new control constructs is not something we'd want to
> do every day, as it can be a great way to obfuscate code beyond all hope
> of understanding--but the same is true of meta-classes. Just because it
> *could* be abused doesn't mean that it would be.
IMO creating New Control constructs is a great and Much needed idea.
More information about the Python-list