Hi, Jean-Claude; thanks for your mail. > GV> Show them [1, "two"] and they (a) understand it, and (b) think > GV> it's cool; show them (1, "two") as well and they become confused. > Because they mean the same thing, I suppose? Redundancy seems to confuse people (did someone say "Perl" or "PL/1"?) > GV> If tuples didn't already exist, would anyone ask for them to > GV> to be added to the language today? > > Why indeed? They are more space-efficient, and they are immutable, > but those are both purely technical reasons. Agreed --- I could understand having tuples as an internal data structure, but do not understand why they are exposed to users. If Python had been a type-checked, type-inferenced langauge from the beginning, I guess I could see it... As for the immutability: >>>> x = [1, 2] >>>> y = (10, x, 11) >>>> y[1][0] = 999 >>>> y (10, [999, 2], 11) > GV> I've never had any trouble explaining int vs. float to students at > Because ints and floats differ in meaning? People are taught "whole numbers" vs. "fractions" at an early age. > GV> I've also never had any trouble explaining int vs. long > GV> (memory vs. accuracy). > > That's interesting. Tuples vs. lists are a similar tradeoff, though > both memory-savings and immutability are CS-type issues, whereas non- > programmers are more likely to consider accuracy a meaningful tradeoff? I just show them the range of values that can be represented in 8, 16, 32, or 64 bits (for ints); 'float' vs. 'double' follows naturally from that. Again, I've never had any trouble with this one... Interestingly, I've also never had trouble with strings being immutable. I point out to people that the number 123 isn't mutable, and that supposedly-mutable strings in other languages are really allocating/deallocating memory behind your back; everybody nods, and we carry on. Greg
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4