[Python-ideas] Variable-length, homogeneous tuple: why? (was: Optional static typing -- the crossroads)
Guido van Rossum
guido at python.org
Mon Aug 18 02:30:37 CEST 2014
On Sun, Aug 17, 2014 at 4:47 PM, Ćukasz Langa <lukasz at langa.pl> wrote:
> On Aug 17, 2014, at 4:40 PM, Chris Angelico <rosuav at gmail.com> wrote:
>
> Et voila. Now just define that frozenlist[int] is like list[int]
> rather than like tuple[int], and there you are, out of your difficulty
> at once!
>
> That's a neat trick and I think Guido suggested this naming before. It
> feels a little icky though, consider:
>
> - issubclass(tuple[int, int, int], frozenlist[int]) ? I think True.
> - issubclass(frozenlist[int], tuple[int, int, int]) ? I would think
> False. But because that's technically the same tuple underneath,
> *sometimes* instances of frozenlist[int] will respond True to
> isinstance(tuple[int, int, int]).
>
> Saying explicitly tuple[int, ...] takes that riddle away.
>
Hm. That looks just as [tr]icky. Plus, I expect both pedants and
ignoramuses may wonder about the empty tuple. :-) I think it deserves a
proper name, not magic syntax.
I do agree that frozentuple sounds odd, but perhaps we just need to get
used to it.
--
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140817/c0d181c8/attachment-0001.html>
More information about the Python-ideas
mailing list