for own(...) loop (spin-off from Re: for..in, hasOwnProperty(), and inheritance)

Dean Landolt dean at deanlandolt.com
Wed Nov 9 13:15:50 PST 2011


On Wed, Nov 9, 2011 at 4:05 PM, Brendan Eich <brendan at mozilla.com> wrote:

> On Nov 9, 2011, at 12:40 PM, Jorge wrote:
>
> > On 08/11/2011, at 22:17, John J Barton wrote:
> >> Just as a point of comparison, I use this form:
> >>  Object.keys(o).forEach( function(key) {
> >>     body
> >>  });
> >
> > By the way, isn't that above a(nother) good use case for a goto, given
> that there's no (easy) way to break out of a forEach 'loop' ?
>
> "goto" as in C, from body to a label in the outer function or script?
> Seriously?
>
> You could always use try/catch/throw, but who would?
>


Umm, es-next, right? In a way, isn't this what StopIteration is? :)

Still, it's a whole lot nicer to just let the language do your try/catch
wrapping where you can. And if you need to break out of forEach, just, umm,
don't use forEach. It's the wrong tool for the job.



> Escape continuations and call/cc are off the agenda.
>
> See http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival-- that's the only way you're going to get break as safer goto to work
> here. There: I closed on a positive note! :-P
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20111109/fd49e0a4/attachment.html>


More information about the es-discuss mailing list