"Collin Winter" <[EMAIL PROTECTED]> writes:

>> > Assume the following is true for a type annotation system:
>> >    (T,) is equivalent to tuple[T]
>> >    (T1, T2) is equivalent to tuple[T1, T2]
>> >    (T1, T2, T3) is equivalent to tuple[T1, T2, T3]
>>
>> This is ambiguous: tuple[T1, T2] is the same as tuple[(T1, T2)],
>> i.e. it's a 1-tuple containing a 2-tuple.
>
> tuple[T1, T2] a 2-tuple with element 1 of type T1 and element 2 of
> type T2. A 1-tuple containing a 2-tuple would be tuple[tuple[T1, T2]].

If tuple[T1, T2] and (T1, T2) are equivalent when interpreted as
annotations, then a 1-tuple containing a 2-tuple can also be written
tuple[(T1, T2)].

But this is already equivalent to tuple[T1, T2] on a more fundamental
level than interpreting values as annotations. Both call __getitem__
with a 2-tuple as the argument, they evaluate to the same value no
matter how __getitem__ is implemented.

Different annotations can be interpreted as the same thing, but the
same annotation can't be interpreted differently depending on
distinctions which have been lost during parsing.

So the following assumptions are mutually contradictory when
considered together, something must be taken away:

- obj[i, j] means obj.__getitem__((i, j)), as today
- annotations are evaluated as expressions
- annotations tuple[T1, T2] and (T1, T2) are equivalent

-- 
   __("<         Marcin Kowalczyk
   \__/       [EMAIL PROTECTED]
    ^^     http://qrnik.knm.org.pl/~qrczak/
_______________________________________________
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