On Tue, Feb 25, 2020 at 3:21 AM Alex Hall <alex.mojaki@gmail.com> wrote:
It is not a question of right or wrong, better or worse. It is a question of being consistent.
Why would that be the question? Why is consistency more important than "better or worse"? How can you make such a bold claim?
Inconsistency leads to ridiculous situations where things change from working to nonworking when you make what should be an insignificant change. Consider: // JavaScript let obj = { attr: 1, method: function() {return this.attr;}, } obj.method() # returns 1 [obj.method][0]() # returns undefined // PHP, older versions - fortunately fixed function get_array() {return array(1, 2, 3);} $arr = get_array(); echo $arr[0]; // Fine echo get_array()[0]; // Broken until PHP 5.something # Python nan = float("nan") nan == nan # False [nan] == [nan] # True Go ahead, explain these differences to a newish programmer of each language. Explain why these behave differently. Now would you like to explain why, with strings, you can say s[0], s[1], s[2] etc, but you can't iterate over it, either with a 'for' loop or with any other construct that iterates (for instance, you can't say a,b,c = s because that is done with iteration). Especially, explain why you can do this with literally every other subscriptable type in the core language (and most from third-party classes too), and it's only strings that are bizarre. Oh but they *aren't* bizarre in older versions, so there'll be code on the internet that works that way, just don't do it any more. Have fun explaining that. Consistency *is* valuable. ChrisA