Guido van Rossum wrote:
> On 4/10/06, Jim Jewett <[EMAIL PROTECTED]> wrote:
> 
>>On 4/10/06, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>>
>>>A completely separate issue is what kind of objects Seq, Index and
>>>Text would be; but that's a discussion we have separate from the
>>>syntactic discussion.
>>
>>What do you mean?  The only question that leaps out at me is whether
>>they should be predicates or constructors.  In other words, should
>>
>>    def f(a:Seq): ...
>>
>>mean something closer to
>>
>>    def f(a):
>>        assert Seq(a)
>>        ...
>>
>>or
>>
>>    def f(a):
>>        a=Seq(a)
>>        ...
> 
> 
> It should mean neither. As I tried to say, the *only* semantics is
> that the value of the expression is accessible through the
> __signature__ attribute of the function. It is then up to the
> decorator to decide what it means.
> 
> 
>>If adaptation is light enough to be useful, then I can't see any
>>reason to prefer the first.
>>
>>    def f(a:0<a<10): ...
>>
>>isn't *that* much cleaner than whichever of
>>
>>    def f(a:clip_to_int_range(0,10)): ...
>>    def f(a:int_in_range(0,10)): ...
>>    def f(a:clip_to_number_range(0,10)): ...
>>    def f(a:number_in_range(0,10)): ...
>>
>>was actually intended.
> 
> 
> That's not something I had considered. It would have to turn the
> expression into an implicit lambda (or an AST), which isn't something
> we should do lightly, and which conflicts with other proposed uses,
> where the value of the expression is made available to the decorator
> -- the value of '0<a<10' is not available until f is *called*.

This seems like it ties into the AST access thread. If some way of 
quoting little chunks of code shows up, this becomes a non-problem since 
you can then do:

     def f(a:`0<a<10`)

[I'm using backquotes for the moment since that's the only syntax I've 
seen proposed] Then the responsibility falls to decorator to something 
sensible with the code fragment. Turning the type specifier into some 
sort of implicit lambda seems like a mess otherwise.

Regards,

-tim



_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to