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

Did you miss that you can't create local variables?


WHAT? You mean, you can't declare them without initialization. Oh well, you can't; it's also impossible in Python or Lua. Why is it a bad thing?


Let's not confuse matters here: in both those languages an initialization-assignment will introduce a new binding within function scopes. In CoffeeScript it will always be the parent scope's binding, which means that you must take extra care not to introduce variables used in scopes above, or below, at any given time.

On the other hand, confusing both concepts is bad because it makes it harder to reason about scope, and it has been the cause of much confusion regarding closures in Python and Ruby.


Lua has perfectly sane lexical scope for its local variables. Don't mix it with Python and Coffeescript.


Ah, true, I checked again and you're right. Too late to edit.


you can if you cheat: http://coffeescript.org/#try:%0Aa%20%3D%201%0Ax%20%3D%20-%3E...

(I jumped ship to babel though)




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

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

Search: