On Tue, Apr 19, 2005 at 01:33:15PM -0700, Guido van Rossum wrote:
@acquire(myLock): code code code
It would certainly solve the problem of which keyword to use! :-) And I think the syntax isn't even ambiguous -- the trailing colon distinguishes this from the function decorator syntax. I guess it would morph '@xxx' into "user-defined-keyword".
How would acquire be defined? I guess it could be this, returning a function that takes a callable as an argument just like other decorators:
and the substitution of
would become something like
def __block(): CODE EXPR(__block)
I'm not yet sure whether to love or hate it. :-)
I don't know what the purpose of these things is, but I do think they should be like something else to avoid learning something new.
Okay, I lied, I do know what these are: "namespace decorators" Namespaces are currently modules or classes, and decorators currently apply only to functions. The dissonance is that function bodies are evaluated later and namespaces (modules and classes) are evaluated immediately. I don't know if adding a namespace that is only evaluated later makes sense. It is only an extra case but it is one extra case to remember. At best I have only channeled Guido once, and by accident so I'll stay out of the specifics (for a bit).
 during the decorator syntax bru-ha-ha at a Boston PIG meeting I suggested Guido liked the decorator-before-function because it made more sense in Dutch. I was kidding, but someone who knows a little Dutch (Deibel?) stated this was, in fact, the case.