[Python-Dev] re: syntax - "Aren't tuples redundant?"

gvwilson@nevex.com gvwilson@nevex.com
Sat, 5 Feb 2000 10:24:50 -0500 (EST)

[Question for Guido at the bottom of the message...]

> Tim Peters wrote:
> I write my code deliberately to follow the guidelines I mentioned
> (tuples for fixed heterogenous products, lists for indefinite
> homogenous sequences).  Perhaps I see it that way because I love
> Haskell too, where those "guidelines" are absolute requirements (btw,
> is Haskell being silly here too in your view?). In Python, I find that
> following them voluntarily is a truly effective aid to both reasoning
> and clarity.

I'm a big fan of Haskell; if Python enforced the distinction you've made,
I would probably never have questioned it.  However:

1) As long as it's just a convention, that only a handful of people
   strictly conform to, it's a pedagogic wart --- every Python book
   or tutorial I've read spends at least a paragraph or two justifying
   tuples' existence.

2) I tried in my first class at LANL to say "tuples are like records".
   One guy put his hand up and said, "Records that you access using
   integer indices instead of names?  *laugh*  Well, it's good to see
   that Fortran-66 is alive and well!" *general laughter*

   The point is a serious one --- Pascal taught us to give meaningful
   names to the fields in structures, and then tuples take us back to
   "oh, I think the day of the month is in the fourth field --- or is
   it the fifth?"

> The distinction between ints and floats is much more a "just so" story
> to me:  your students never questioned it because their previous
> languages (Fortran and C++ and ...) told them the same story.

That's part of it --- but again, I think the Logo community found that
novice non-programmers understood "whole numbers vs. fractions" without
any trouble.  Don't remember if rounding (assigning float to int) was a
problem or not; I'll ask Brian H.

> >   If tuples didn't already exist, would anyone ask for them to
> >   to be added to the language today?

> I probably would, because I grew to like the distinction so much in
> Haskell, and would *expect* the Haskell benefits to carry over to
> Python as well.

Given enforced typing (fixed-length heterogeneous vs. variable-length
homogeneous), I'd agree.

Guido, if you're still on this thread, can you please tell us about the
history here --- were list and tuples both put into the language with
this kind of distinction in mind?

Thanks for your patience,