3 ms·
sane has nothing to do with static typing. Python is a language which is dynamic and has a sane semantics. e.g. in JS {} + {} is NaN and many other examples.
by lukasm 13y ago
sane has nothing to do with static typing. Python is a language which is dynamic and has a sane semantics. e.g. in JS {} + {} is NaN and many other examples.
- jkrems 13y agoThere's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?
- pekk 13y agoIf it does anything at all, it certainly shouldn't generate NaN
- tel 13y agoWhy not? If (+) is numeric addition and coercion is free then {} is NaN and so is {} and so is NaN + (anything) and so is (anything) + NaN. Which is not to say that it's a good choice, but instead to say that the badness stems from overloading (+) too much and having free coercion.
- anonymouz 13y agoIt's obviously {}, duh! ;) (In one of the ways of constructing the natural numbers within ZFC set theory in mathematics, one identifies 0 with the empty set {}, 1 with {{}}={0}, 2 with { {}, {{}}} = {0,1}, and so on.)
- tel 13y agoRight, sane semantics: http://cs.brown.edu/research/plt/dl/lambda-py/lambda-py.pdf http://cs.brown.edu/research/plt/dl/lambda-py/lambda-py.pdf Saner perhaps, but still ungodly complex with weird edge cases.
- rubiquity 13y agoHow would using TypeScript fix that?