News for hackers. Stuff that matters.
Re:Functional JavaScript: Closure by Torn on Tuesday June 18, 2013 @03:04PM (#5901284)
Which for loops don't require a mutating index? (apart from the object property "for __ in __" iterator)
Re:Functional JavaScript: Closure by tieTYT on Tuesday June 18, 2013 @03:21PM (#5901375)
Those ones. But what I meant was that it is idiomatic to use for loops vs recursion.
Re:Functional JavaScript: Closure by michaelsbradley on Tuesday June 18, 2013 @04:17PM (#5901771)
That's true, and may be reinforced somewhat by the fact that JavaScript doesn't eliminiate tail calls. In other words, there are situations where a recursive algorithm would be clean and compact, but might result in the call stack being blown inadvertently.

I ran into this recently while building a "practical" monads library for JavaScript. Each monad and transformer has sync and async variants. The sync variants can't use straight recursion because "deep" monadic binds will result in a blown call stack. The solution was/is to allocate on the heap in terms of an array that acts as a manually operated call stack (I think I essentially implemented a "trampoline" but I'm not 100% certain).

Re:Functional JavaScript: Closure by mackwic on Tuesday June 18, 2013 @03:24PM (#5901399)
Considering that recursive loop with bounds is a sort of for loop, recursive for.