3 ms·
This makes me wonder what the point of writing 'var' is if it doesn't tell you the type of the variable.
by Retra 12y ago
This makes me wonder what the point of writing 'var' is if it doesn't tell you the type of the variable.
- UberMouse 12y agoSo variables are explicitly declared, don't have issues of mis typing a variable name and accidentally declaring a new one. Note: This is just my thinking, I don't know if it's the actual reason
- Retra 12y agoThat's a sensible reason, sure, but I'd rather declare it with an actual type instead.
- tomp 12y agoAs opposed to doing what?
- thomasahle 12y agoLike python, just `e = equal(...`
- tomp 12y agoPython had to go through a lot of pain for that, the "nonlocal" keyword was only added in Python 3.0, and the local/global distinction is very fragile. Javascript and Coffeescript try to solve this in different ways, most people think that JavaScript's method sucks, and many are not fond of CoffeeScript's non-locality. Personally, I think that demanding variable declaration is still the best option (possibly except for interactive sessions).
- thomasahle 12y agoYes, for complicated things like this, explicitly declaring the type is probably preferable.