Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

There's a language where `{} + {}` does something useful? Or is the complaint that it should `TypeError`?


It'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.)


If it does anything at all, it certainly shouldn't generate NaN


Why 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: