3 ms·
These are great changes, and a reminder that I must find a reason to write more Erlang. For the record, one of these is another thing JavaScript got right, sor
by Cushman 13y ago
These are great changes, and a reminder that I must find a reason to write more Erlang.
For the record, one of these is another thing JavaScript got right, sort of, with named function expressions:
setTimeout(function innerName() {
if (shouldRecurse())
innerName();
});
typeof innerName; // undefined
I don't think I've ever seen anyone actually use this in production code, of course. And you're free to have your own issues with function declarations and named function expressions having the exact same syntax, which causes a big problem in IE<=8 that is probably responsible for this feature not being in common use (and omitted from CoffeeScript, alas).
- masklinn 13y agoYou can also do that in Clojure, since you'd usually self-recurse with (recur) and a function will create a recursion point. (set-timeout (fn [] (if (should-recurse) (recur)))
- Morgawr 13y agoYou can also name fns in clojure (map (fn whatever [a] (println a)) [1 2 3]) ps: this code is stupid but I'm too lazy to write useful clojure from my phone, you get the gist
- draegtun 13y agoAnd you can also do that in Perl: set_timeout sub { __SUB__->() if should_recurse(); }; NB. __SUB__ was added at Perl 5.16 and so requires either: use 5.016; # or newer use feature 'current_sub';