Label statement moveable

Bob Myers rtm at gol.com
Thu May 21 13:04:34 UTC 2015


Can we also get goto statements?

Also, if we going to do gotos, then please implement computed GOTO. FORTRAN
has had that already for like 50 years.


Bob

---------- Forwarded message ----------
> From: "Sébastien Doeraene" <sjrdoeraene at gmail.com>
> To: Emanuel Allen <emanuelallen at hotmail.com>
> Cc: "es-discuss at mozilla.org" <es-discuss at mozilla.org>
> Date: Wed, 20 May 2015 22:38:09 +0200
> Subject: Re: Label statement moveable
> Hi,
>
> On Wed, May 20, 2015 at 7:46 PM, Emanuel Allen <emanuelallen at hotmail.com>
> wrote:
>
>> So my first attempt example would actually be rewritten to:
>> var i;
>> foo:{
>>   if(typeof i!=='number') break;
>>   i+=1;
>> }
>> 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;
> do {
>   if (typeof i !== 'number') break;
>   i += 1;
> } while (i < 5);
> console.log(i);
>
> (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?
>
> Cheers,
> Sébastien
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150521/eb783392/attachment.html>


More information about the es-discuss mailing list