The problem with "as" [was "Re: PEP 318"]

Joe Mason joe at notcharles.ca
Tue Mar 23 09:39:19 CET 2004


In article <slrnc5vrl2.vi6.joe at gate.notcharles.ca>, Joe Mason wrote:
> Not a big fan of that syntax - I have to keep the parameter names and
> types in sync by counting.
> 
>     def foo(x [accepts(int)], y [accepts(float)]) [returns(int)]:
> 
> is a little better, except now we're getting very verbose.
> 
> For decorators in general, I like
> 
>     def foo() as [decor1, decor2, decor3]:
>     
> You get an explicit list syntax, but it's set off by a keyword so they don't
> run together to the eye.  Because the keyword keeps it unambiguous, you
> could even allow a tuple instead of a list: "def foo() as (x, y, z)".
> 
> So I definitely favour a keyword, but perhaps "as" is to generic.  What
> about "has" or "with"?

Come to think of it, the verbose example with "has" becomes (assuming a
shorter decorator name):

    def foo(x has sig(int), y has sig(float)) has returns(int):

Since you might not need the full list syntax for a single decorator.
That's not too bad looking.

(No, I'm not seriously proposing decorators on parameters at this point.)

Joe



More information about the Python-list mailing list