On that note, how the hell would you understand currying or do notation by trial and error?
I wonder if they implemented one of their languages with true wrapping index behaviour.
But as @justinpombrio says, this is also tied to a particular pedagogy. The day after the homework is due, in class, we:
- collectively build up a classifier (programs that tell the languages apart)
- present the intended theory (our ground truth of what is going on)
and then spend the remaining time (30+ minutes) talking about which languages did those particular things, and — most importantly — why those languages did that, especially for the "weird" behaviors. There were often very good reasons for doing so, when viewed in a historical context. In this regard, I'm very much a historicist in the Kuhnian sense.
No, that was just me writing carelessly. None of the mystery languages use array indexing, and if they did we'd be careful to get it right. I actually know this behavior of Python, but didn't think about it much as I wrote.
> On that note, how the hell would you understand currying or do notation by trial and error?
It's not easy, but many of our mystery languages are harder than this, and our students figure them out! Sometimes they'll get 2/3 of the way to a solid explanation, and then Shriram gives them a canonical explanation in class the next day, while it's fresh in their minds. And sometimes they come to a perfect understanding by themselves.
And currying could make a good mystery language. Thanks for the idea!
> EDIT: Specifically, Python wraps negative indices that are smaller than the length of the array.
(But that's not quite correct either. 3 is not smaller than the length of a, but a[-3] worked.)
Python doesn't wrap indices to a valid one. However, it does allow for negative indices which are shorthand for the length of the list plus that negative index.