3 ms·
I don't think it violates any important least-surprise principle. You might be surprised to see it used -- but you don't get surprised when the code behaves ho
by SamReidHughes 8y ago
I don't think it violates any important least-surprise principle. You might be surprised to see it used -- but you don't get surprised when the code behaves how the documentation says it will.
- fjsolwmv 8y agoLeast surprise doesn't mean everything is documented. It means things behave analogously to everything else
- ergothus 8y agoBut language attempts to resemble spoken language precisely so we don't have to rely on the documentation alone. We use if/else, not "xan/ka" because we want to leverage the existing meaning of those words. In the early stages of Perl 6 design I requested a for/else feature where the "else" block fired if and only if the for loop had never been entered...the opposite of how this works. Being literally the opposite of how I would write it qualifies as surprising to me.
- SamReidHughes 8y agoNaming is useful for getting adoption but not when you already know the language. And in your case you might have been surprised, but that's because you'd take a guess at what the feature does instead of finding out. (I don't think for/else is the best option, gotos are. It's just not a harmful feature, the way other aspects of Python are.)