Yes:

> foo: {
>     // ...
>     if (bar)
>         continue foo // (currently a SyntaxError)
>     // ...
> }


in my first attempt at posting this I did something similar:

 function foo(v){
> 
>>>>  return v + 1;
>>>> }
>>>> 
>>>> 
>>>>  var i = 0;
>>>> 
>>>>  baz:{
>>>>    i += 1;
>>>>  }
>>>> 
>>>> continue baz;//same as foo(i);
>>>> 
>>>> console.log(i);

But not that I want restriction on where continue can be use; only in block 
scope. Rather that's in an if/else else if statement or a function statement.


And another important thing is I want label statement reachable from the scope 
they are define.

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. 


JS4Lf

> On May 20, 2015, at 11:56 AM, Claude Pache <[email protected]> wrote:
> 
> I occasionally (quite rarely) use the following variant of the classical 
> `do/while(false)` trick:
> 
> ``
> foo: do {
>     // ...
>     if (bar)
>         continue foo // meaning: restart from foo
>     // ...
>     break 
> } while (true) // not a real loop, just a hack
> ```
> 
> Maybe the following syntax could be used?
> 
> ```
> foo: {
>     // ...
>     if (bar)
>         continue foo // (currently a SyntaxError)
>     // ...
> }
> ```
> 
> WDYT?
> 
> —Claude
> 
> 
>> Le 20 mai 2015 à 12:45, Sebastian McKenzie <[email protected]> a écrit :
>> 
>> So you want to add goto to JavaScript?
>> 
>> 
>> 
>> 
>>> On Wed, May 20, 2015 at 11:42 AM, Emanuel Allen <[email protected]> 
>>> wrote:
>>> Clarify:
>>> 
>>> My previous post was not that clear. That post display what I would like to 
>>> do in the language. Here is the actual code if I choose to do it as the 
>>> language is now: 
>>> var i = 0, n = 5;
>>> l2: do {
>>>  i += 1;
>>>  l3: do {
>>>    if (i<n) continue l2;
>>>    else break l3;
>>>  } while (true);
>>>  break l2;
>>> } while (true);
>>> //just log the value n+1:
>>> console.log('i:'+i);
>>> 
>>> loop through label l2 n amount of times before breaking.
>>> 
>>> This could be useful to escape function invocation cost, if it could be 
>>> simply express:
>>>  l2: {
>>>   i += 1;
>>>  }
>>>  l3: {
>>>    if (i<n) continue l2;
>>>  }
>>> 
>>> The function way is to:
>>> function l2(){
>>>   i += 1;
>>> }
>>> 
>>> l3: do {
>>>    if (i<n) l2();
>>>    else break l3;
>>>  } while (true);
>>> 
>>> I did a <a href="http://jsperf.com/block-scope-vs-function-invocation";>
>>> jsprf </a>to further my argument for a sudo goto/function effect:
>>> 
>>> http://jsperf.com/block-scope-vs-function-invocation
>>> 
>>> JS4Lf
>>> 
>>>> On May 19, 2015, at 2:45 PM, L4L <[email protected]> wrote:
>>>> 
>>>> Since we have block scope, and we have continue statement to which we can 
>>>> use in loops to jump back to the conduction statement part. 
>>>> 
>>>> Than can we consider making label stamens moveable by its name. 
>>>> 
>>>> I'll like to say that the side effect would be sudo(pseudo) function, 
>>>> example:
>>>> 
>>>> function foo(v){
>>>>  return v + 1;
>>>> }
>>>> 
>>>> 
>>>>  var i = 0;
>>>> 
>>>>  baz:{
>>>>    i += 1;
>>>>  }
>>>> 
>>>> continue baz;//same as foo(i);
>>>> 
>>>> console.log(i);
>>>> 
>>>> Note that I said sudo function. Its mobility is what of value; depending 
>>>> on how JavaScript handle the continue statement in a loop to transport 
>>>> that effect out side a loop. 
>>>> 
>>>> Stripping this privilege to black scope; where the continue statement is 
>>>> expanded to work only in block scope and nested block scope; to where it 
>>>> can only jump to the beginning of that block or any other block scope that 
>>>> is scoped to that outer block scope but not nested block scope with in the 
>>>> scope... Like function.
>>>> 
>>>> Continue and break statement could be of more power; where we can avoid 
>>>> some function call in "speed matter" application.
>>>> 
>>>> Excuse any grammar errors. 
>>>> 
>>>> JS4Lf
>>>> _______________________________________________
>>>> es-discuss mailing list
>>>> [email protected]
>>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> _______________________________________________
>> es-discuss mailing list
>> [email protected]
>> https://mail.mozilla.org/listinfo/es-discuss
> 
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to