mixing statements into J2

Robert Brewer fumanchu at amor.org
Thu Aug 26 13:36:08 EDT 2004


> > >       Can we insert conditional expressions in the 
> decorator list ?
> > 
> > Not with the current patch; however, that option may be 
> allowed in the future.
> 
> "In the future" means "post-2.4, when we have an idea of what people
> are doing with it". Right now, there's not a whole lot of use cases
> for more complex expressions in the decorator area, and there's more
> potential for horror. Guido made this call on a gut feeling, not on
> any technical grounds. His gut is usually good on this.
> 
> > The order of operation would have to be reversed,
> 
> I don't see why.

It's not a requirement, but it seems reasonable to me. If you're going
to set off a decorator suite and then mix in normal Python statements,
the two models collide over order of operation:

using:
    if test:
        memoize
    else:
        synchronize
    classmethod
def foo(self, *args):
    stuff(args)

The statements get evaluated top-to-bottom, but the decorators get
applied bottom-to-top. It would be one more confusing issue in an
already-confusing syntax. Not to mention that the current patch pushes
decorators onto the stack at compile-time, and then pops them off after
the function def. Mixing statements into the suite would move decorators
from compile-time to runtime (at least, I don't see any way to avoid
that without introducing a whole new layer of pragmas).

If I felt it were possible, I would have recommended that application
order in J2 be the opposite of A1. But I figured that would cause
another two weeks of debate, which we don't have. I certainly see that
"using:" provides a case for top-to-bottom, where "@decorator" implies
the opposite.

> > so *IF* Guido votes yes, 
> > then you need to bring this up again immediately.
> 
> God no. Please don't. Work with the syntax that's chosen, then we can
> revisit this for 2.5.

Waiting until then guarantees the question won't be addressed, due to
backward-compatibility issues which we will have then which we do not
have now. Which I'm willing to concede to be a foregone conclusion at
this point. Perhaps it would be enough just to say (to Guido), "this is
still an open issue (one of many)"?


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list