48 questions
0
votes
1
answer
36
views
In a three nested for loop with labeled break, why is the output the same when the labeled break is positioned in the inner and middle loop?
Why is the output exactly the same when the labeled break is positioned before the start of the middle and inner loop?
Example code 1 - When break point is positioned at the start of the inner loop
...
2
votes
1
answer
312
views
Labelled functon statement - Undefined label
I look at spec and I can't understand why this code cause an error:
L: function a(){
console.log(1);
break L; /// Uncaught SyntaxError: Undefined label 'L'
console.log(2);
}
a();
In the same ...
1
vote
1
answer
52
views
Is it possible to use labeled statements with `throw`?
I have a chain of throwing calls that I need to catch, and then I need to use their result to - maybe - throw something anyway, despite all of them succeeding:
func a() throws {
do {
let b ...
0
votes
1
answer
85
views
Labeled statements / gotos in javascript
Is there a legitimate usage of using labeled statements in javascript, or is this something that is not really used in production code but just in the spec? For example, I was having the hardest time ...
1
vote
1
answer
524
views
Do we have labeled Statements in Typescript similar to what we have in JS?
I found this very interesting that we can break or continue a loop in Javascript. Do we have a similar concept in Typescript (Angular)?
let str = '';
loop1:
for (let i = 0; i < 5; i++) {
if (i ==...
0
votes
1
answer
128
views
Combine settimeout and label Loop and if statement [duplicate]
The following code is work as the following
while loop>> bring a and b values>> settimeout>> check the value by if-condition>> continue it true, else break;
This code with ...
-2
votes
3
answers
192
views
How to use goto without getting this error? [closed]
#include <stdio.h>
int main()
{
repeat:
printf("choose an option: \n1:Draw\n2:Even or Odd:\n3:Text type\n4:How to Dec\n5:Base to Dec:\n6:Count to Bits\n0:Exit\n");
int x;
...
-1
votes
2
answers
228
views
ANTLR GOTO statement
I'am working on simple parser for code:
DEF Test( )
a = false
b = false
c = false
IF a THEN
GOTO LabelA
ENDIF
IF b THEN
GOTO LabelB
ENDIF
IF c THEN
GOTO LabelC
ENDIF
GOTO LabelD
LabelA:
$...
2
votes
4
answers
668
views
Labeled break just after loop not working in Java
for(int x = 0; x < 5; x++)
stop2: {
System.out.println("Count");
if (x == 2)
break stop2;
}
stop3: for(int x = 0; x < ...
35
votes
5
answers
5k
views
What is this : sign after a variable JS syntax?
I came across the following valid syntax in JS when looking at svelte library:
$: doubled = 6 * 2;
At first, I thought it was specific for the library, but it works on the Chrome console. What is ...
1
vote
1
answer
55
views
Can the label for a break have any name?
I am learning java after coming over from python. The book I am reading is currently discussing breaks, which I am familiar with. When it comes to labeled breaks, can I give the label any name I ...
0
votes
3
answers
1k
views
how to jump from one for loop to another for loop using label in java?
when i am trying to access for loop from another loop i get following errors.
how can i do that can somebody explain.
public class Test {
public static void main(String...rDX) {
runing:
...
1
vote
4
answers
1k
views
Labeled loop in Java
I having been staring at my screen for a while and I do really need an explanation for labeled loop in this scenario:
package com.misterkourouma.oca8.starter.test;
public class LabeledLoop{
...
1
vote
1
answer
628
views
labeled statement - incorrect definition?
For JavaScript's label syntax, JS MDN states:
label :
statement
label: Any JavaScript identifier that is not a reserved word.
statement: A JavaScript statement.
break can be ...
5
votes
1
answer
561
views
What happens in `let:let{let:[x=1]}=[alert(1)]`?
I’m watching a talk on JSON hijacking and not 2 minutes in, there is already JavaScript that is unfamiliar to me.
let:let{let:[x=1]}=[alert(1)]
It seems to work on Edge and just alerts 1, but I’ve ...
18
votes
2
answers
23k
views
Label can only be used as part of a statement Error
I have been looking through the forums but I have not found an answer to this question that applies to my situation. I am trying to make a system call to using 'sort' (unix), however, I receive an ...
11
votes
1
answer
9k
views
Is there such a thing as labeled or unlabeled break in C?
As is the case in Java where the break statement can be labeled or unlabeled, is there a statement in C which is either the equivalent or achieves the same process?
3
votes
2
answers
72
views
Javascript Conflicting Syntax Between Function As Object Key And Labeled Function in Block
Assuming you have a browser that supports both labeled function declarations and block statements, what is the standard way/method for browsers to determine if the following is an object with a ...
0
votes
2
answers
50
views
Is it a browser bug that I can't use js labeled statements with an if?
Disclaimer: Yes, I know goto is bad, I'm interested here in the spec and implementations, not best practices.
I have this super simple javascript example of a labeled statement
let i = 0;
foo:
if(i &...
-2
votes
1
answer
5k
views
HTML JAVASCRIPT goto label? [duplicate]
I need your help, I wish to do a "goto" like "goto" in batch :
:loop1
goto loop1
but in javascript for html page, all my research are useless...
it can be so usefull to know that !...
0
votes
1
answer
240
views
Javascript Label
Mozilla Developer Network states that
Statement 1 : "The labeled statement can be used with break or continue statements. It is prefixing a statement with an identifier which you can refer to."
...
-2
votes
1
answer
965
views
Android - How to use labeled statements
I am working on a project for which I have reverse engineered the code of other project. But, the code contains so much goto statements and a label with it.
I tried to rearrange the code as per the ...
0
votes
3
answers
1k
views
iOS break loop with switch
I have a loop like this:
label: for(X *y in z)
{
switch(y.num)
{
case ShouldDoSomething:
[self somethingWithX:y];
break;
case ...
13
votes
3
answers
40k
views
How to use labels in java?
I am getting error while using break statements in labels in java code. This is showing undefined label. It is wrong to write code like this. Please assist me in using it correctly. Thanks in advance.
...
1
vote
1
answer
393
views
Should I Ever Use Labels In Javascript? (If So, When?)
Backstory: Once again I was reading in my Javascript book and I bumped into something that the book didn't explain very well, and that I wasn't able to find any good examples of online.
Example from ...
0
votes
2
answers
165
views
Nested Javascript for loops with break and label statements
I'm kinda new to Javascript and currently going over the book Professional Javascript for Web Developers and I came across this code which uses a break statement to exit the current loop and jump to a ...
4
votes
1
answer
79k
views
How to go back to a specific line in Java?
I'm writing code that involves an if-else statement asking the user if they want to continue. I have no idea how to do this in Java. Is there like a label I can use for this?
This is kind of what I'm ...
7
votes
2
answers
2k
views
Can java labels be used appropriately outside of for loops?
So I've seen a lot of cases where labels are being used in for loops to break out, especially with doubly nested loops.
Is this the only case where they can be used? or are there other common uses ...
3
votes
5
answers
17k
views
Using label and break in if-else statement
I have this code which generates random number from an array, at a particular condition (when x and y both are equal to zero). I want the control to jump to the label. But the control never jumps to ...
17
votes
6
answers
5k
views
What's the point of using labeled statements in Java? [duplicate]
I'm busy studying for my certification and I stumbled upon a concept I've never even heard before - "Labeled Statements". e.g:
'label' : 'statement'
L1: while(i < 0){
L2: System.out.println(...
8
votes
1
answer
4k
views
What's wrong with using a labelled statement in global code?
I was just browsing the source of JSLint and noticed this piece of code:
// Is this a labeled statement?
//...
if (next_token.labeled !== true || funct === global_funct) {
stop('...
0
votes
1
answer
230
views
Is there any way to access the current label set in JavaScript/ActionScript
If I create a trivial labeled statement such as:
foo: do { alert('hi') } while (false)
Is there any way to clone foo?
13
votes
2
answers
25k
views
break and label, "The label MyLabel is missing"
I have a code like this:
if(condition1)
{
break MyLabel;
}
while(true)
{
//some code here
MyLabel: if(condition2) break;
//more code here
}
and I get this error:
The label MyLabel ...
8
votes
2
answers
471
views
How are labels used with statements that are not a loop?
According to the ECMAScript 5.1 spec, section 12.12, any statement can be labelled - and in a brief test my browser accepted a label before any statement. The spec also states that labels are used ...
6
votes
3
answers
175
views
Why do labels exist?
Why do labels exist in javascript?
var i = 0;
usefulLabel://why do I exist?
while(i <= 10){
document.writeln(i);
i++;
if(i > 5)
break;// usefulLabel;
}
The above code doesn'...
31
votes
4
answers
9k
views
Address of labels (MSVC)
We are writing a byte-code for a high-level compiled language, and after a bit of profiling and optimization, it became clear that the current largest performance overhead is the switch statement we'...
11
votes
4
answers
11k
views
Why is this labeled javaScript continue not working?
I am using this code to weather some circles are overlapping:
iCantThinkOfAGoodLabelName:
x = genX(radius);
y = genY(radius);
for(i in circles) {
var thisCircle = circles[i];
if(Math.abs(x-...
19
votes
6
answers
18k
views
what the difference between break with label and without label in javascript
var num = 0;
for(var i = 0; i < 10; i++){
for(var j = 0; j < 10 ; j++){
if(i == 5 && j == 5){
break;
}
num++;
}
}
console.log(num)
In the above ...
14
votes
6
answers
22k
views
using labels in java without "loops"
I always thought that the labels must be used only with loops but it seems not. Giving such code:
public class LabelTest {
public static void main(String[] args) {
label1: System.out....
62
votes
5
answers
37k
views
Is using labels in JavaScript bad practice?
I just found out about using label s in JavaScript, such as:
for (var i in team) {
if(i === "something") {
break doThis: //Goto the label
} else {
doThat();
}
}
doThis: //...
127
votes
12
answers
63k
views
"loop:" in Java code. What is this, and why does it compile?
This code just made me stare at my screen for a few minutes:
loop:
for (;;) {
// ...
}
(line 137 here)
I have never seen this before, and I had no idea Java has a "loop" keyword (NetBeans doesn'...
8
votes
3
answers
1k
views
what programming languages support labels with break and continue statments?
I recently read about labelled statments in java and the ability to specify a label with the break and continue statements. What other languages support this sort of syntax ?
8
votes
3
answers
10k
views
Please explain the usage of Labeled Statements
Is breaking and continuing the only uses of labeled statements in Java?
When have you used Labeled Statements in your programs?
Sorry the code snippet has been deleted. I am splitting the question
8
votes
5
answers
5k
views
Can a LABEL block be used without loop?
Can a LABEL block be used without loop? Any examples?
6
votes
4
answers
2k
views
Why should I avoid using Java Label Statements?
Everywhere across the internet people say that you should avoid using label statements in java. However, I find them very useful in some cases, namely nested loops.
I cannot find satisfactory answers ...
78
votes
14
answers
46k
views
Is it possible to store the address of a label in a variable and use goto to jump to it?
I know everyone hates gotos. In my code, for reasons I have considered and am comfortable with, they provide an effective solution (ie I'm not looking for "don't do that" as an answer, I understand ...
42
votes
1
answer
16k
views
is there a equivalent of Java's labelled break in C# or a workaround
I am converting some Java code to C# and have found a few labelled "break" statements (e.g.)
label1:
while (somethingA) {
...
while (somethingB) {
if (condition) {
...
87
votes
10
answers
94k
views
Why "The system cannot find the batch label specified" is thrown even if label exists?
While running a batch file in Windows XP I have found randomly occurring error message:
The system cannot find the batch label specified name_of_label
Of course label existed. What causes this ...