Label statement moveable
sjrdoeraene at gmail.com
Wed May 20 20:38:09 UTC 2015
On Wed, May 20, 2015 at 7:46 PM, Emanuel Allen <emanuelallen at hotmail.com>
> So my first attempt example would actually be rewritten to:
> var i;
> if(typeof i!=='number') break;
> I =0;
> if (i < 5);
> continue foo;
> console.log(i);//log 4
> Again the true aim for this is to lower function calls.
And what about this, which is the *exact* equivalent of your code, without
even a label:
var i = 0;
if (typeof i !== 'number') break;
i += 1;
} while (i < 5);
(Btw, in this instance, the "typeof" test is not necessary at all. I left
it there to better see the connection with the original code.)
You really don't need what you think you need. If you want to "lower
functions", you can just as well inline them *where they're supposed to be
called*, instead of above or at any arbitrary place, which nulls out the
need for "goto" statements.
I also fail to see whether you're approaching this problem from the point
of view of a) write this by hand, or b) the output of a compiler. Your text
suggests a), but the code can obviously be written easily in the do..while
form I wrote over there, in a much more readable way, so the write-by-hand
hypothesis seems weird, which suggests b). Could you make this clearer?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss