4 ms·
I always felt that function hoisting is harming code readability. I prefer reading the code from top to bottom, I don't want to stuble upon functions that were
by jarek-foksa 14y ago
I always felt that function hoisting is harming code readability. I prefer reading the code from top to bottom, I don't want to stuble upon functions that were not declared before.
If I recall correctly the main reason why this feature is not supported by CoffeeScript is because of some awkward IE bug though.
- jashkenas 14y agoThe main reason is what you say -- it harms readability. Much better to have functions behave like any other value, like any other variable -- and only be usable after they've been created.
- tripzilch 14y agoI agree, although I also see some usefulness: If your inner function names are sufficiently descriptive, you can write the high-level behaviour of the outer function at the top, first to be read, to get a quick overview of what it does. Then declare the inner functions below that (this also requires that the inner functions must not have surprising side-effects). I've never seen or tried out code like that in practice, but it seems like it could work.