Re:Things I Learned Writing a Fibonacci Generator in JavaScript
by gravypod on Tuesday May 17, 2016 @03:35PM
(#11716628)
While I do agree generators offer some amazing features, I think they also offer some complexity that we are currently not ready to handle.
from a given for loop:
for (x in function())
Please tell me when this for loop will end. You cannot.
If you instead did...
next = fib()
while (true) {
number = next();
}
You are instantly presented for every case in which this loop will terminate.
Now don't get me wrong, I DO fully agree that a generator is the correct method for doing this, I'm just pointing out another construct to allow you to do this.
from a given for loop:
Please tell me when this for loop will end. You cannot.If you instead did...
You are instantly presented for every case in which this loop will terminate.Now don't get me wrong, I DO fully agree that a generator is the correct method for doing this, I'm just pointing out another construct to allow you to do this.