On 4/10/06, Guido van Rossum <[EMAIL PROTECTED]> wrote:

> The only syntax that is acceptable to me ... would look like

> def fn(a: Seq, b: Index, c: Text = "default"): ...

> where Seq, Index and Text can be expressions (the main problem with
> the syntax you propose is that the type can't be much more than an
> identifier before it gets ambiguous or unreadable).

I agree that putting the identifier after the type (and wrapping to
one parameter per line) allows for a longer expression.

On the other hand, it also allows for a *much* longer expression,
which becomes unreadable anyhow.  Whether this would be enough of a
problem in practice to justify requiring identifiers ... I'm not sure.
 Maybe the actual usage of conditional expressions will help answer
that.

> 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)
        ...

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.

-jJ
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
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