[Python-Dev] Extended Function syntax
Michael Hudson
mwh@python.net
23 Jan 2003 11:30:13 +0000
Just van Rossum <just@letterror.com> writes:
> Jim Fulton wrote:
>
> > In particular:
> >
> > def name(arg, ...) [expr1, expr2, expr3]:
> > ...body...
> >
> > would be equivalent to (some variation on):
> >
> > def name(arg, ...):
> > ...body...
> >
> > name=expr1(expr2(expr3(name)))
>
> With Michael's patch (which indeed still works) it's actually
>
> name = expr3(expr2(expr1(name)))
I can't remember if that was deliberate or accidental. I think
deliberate.
> > I wonder if the same mechanism could be used in class statements.
> > If I had this, I might say what interface a class implements
> > with:
> >
> > class foo(spam, eggs) [implements(IFoo, IBar)]:
> > body of class
> >
> > or (wo parens):
> >
> > class foo [implements(IFoo, IBar)]:
> > body of class
>
> I don't know how Zope interfaces work, but I can imagine the following
> could be made to work as well:
>
> class foo(spam, eggs) [IFoo, IBar]:
> body of class
>
> I think this would be wonderful. Would someone be interested in
> extending Michael's patch to also cover the class statement?
Maybe even me :-) It wasn't very hard.
http://starship.python.net/crew/mwh/hacks/meth-syntax-sugar-2.diff
You still can't use lambdas in the filter list. I thought I'd fixed
that ages ago, but it seems not.
Cheers,
M.
--
I have no disaster recovery plan for black holes, I'm afraid.
Also please be aware that if it one looks imminent I will be
out rioting and setting fire to McDonalds (always wanted to do
that) and probably not reading email anyway. -- Dan Barlow