Label (computer science)
In programming languages, a label is a sequence of characters that identifies a location within source code.[src] In most languages, labels take the form of an identifier, often followed by a punctuation character (e.g., a colon).[src] In many high-level languages, the purpose of a label is to act as the destination of a GOTO statement.[src] In assembly language, labels can be used anywhere an address can (for example, as the operand of a JMP or MOV instruction).[src] Also in Pascal and its derived variations.[src] Some languages, such as Fortran and BASIC, support numeric labels.[src] Labels are also used to identify an entry point into a compiled sequence of statements (e.g., during debugging).[src]
In programming languages, a label is a sequence of characters that identifies a location within source code.[src] In most languages, labels take the form of an identifier, often followed by a punctuation character (e.g., a colon).[src] In many high-level languages, the purpose of a label is to act as the destination of a GOTO statement.[src] In assembly language, labels can be used anywhere an address can (for example, as the operand of a JMP or MOV instruction).[src] Also in Pascal and its derived variations.[src] Some languages, such as Fortran and BASIC, support numeric labels.[src] Labels are also used to identify an entry point into a compiled sequence of statements (e.g., during debugging).[src] void foo(int number) { if (number Here error is the label.[src] The statement goto can be used to jump to a labeled statement in the code.[src] After a goto , program execution continues with the statement after the label.[src] switch (die) { default: printf("invalid\n"); break; case 1: case 3: case 5: printf("odd\n"); break; case 2: case 4: case 6: printf("even\n"); break; } Within a single switch statement, the integer constant associated with each case label must be unique.[src] There may or may not be a default statement.[src] There is no restriction on the order of the labels within a switch.[src] The requirement that case labels values evaluate to integer constants gives the compiler more room for optimizations.[src] top: //Label the outermost for-loop.[src] for (var i = 0; i It also possible to use break statement to break out of the code blocks: top: { console.log("foo") console.log("bar") break top console.log("baz") } // Which would output: // > foo // > bar (let ((iteration NIL)) (tagbody start (print 'started) (setf iteration 0) increase (print iteration) (incf iteration 1) (go check) check (if (>= iteration 10) (go end) (go increase)) end (print 'done))) A second method utilizes the reader macros #n= and #n# , the former of which labels the object immediately following it, the latter refers to its evaluated value.[src] Labels in this sense constitute rather an alternative to variables, with #n= declaring and initializing a “variable” and #n# accessing it.[src] The placeholder n designates a chosen unsigned decimal integer identifying the label.[src] (progn #1="hello" (print #1#)) Apart from that, some forms permit or mandate the declaration of a label for later referral, including the special form block which prescribes a naming, and the loop macro that can be identified by a named clause.[src] Immediate departure from a named form is possible by using the return-from special operator.[src] (block myblock (loop for iteration from 0 do (if (>= iteration 10) (return-from myblock 'done) (print iteration)))) (loop named myloop for iteration from 0 do (if (>= iteration 10) (return-from myloop 'done) (print iteration))) In a fashion similar to C, the macros case , ccase , ecase , typecase , ctypecase and etypecase define switch statements.[src] (let ((my-value 5)) (case my-value (1 (print "one")) (2 (print "two")) ((3 4 5) (print "three four or five")) (otherwise (print "any other value")))) (let ((my-value 5)) (typecase my-value (list (print "a list")) (string (print "a string")) (number (print "a number")) (otherwise (print "any other type")))) ==See also== Line number ==References==[src]
29 sentences · 29 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"Label (computer science)." encyclopegia.org, 2025, https://encyclopegia.org/wiki/label-computer-science. Accessed 27 November 2026.
Chicago
"Label (computer science)." encyclopegia.org. Accessed November 27, 2026. https://encyclopegia.org/wiki/label-computer-science.
APA
encyclopegia.org. (2025). Label (computer science). Retrieved November 27, 2026, from https://encyclopegia.org/wiki/label-computer-science
Accessed November 27, 2026 · CC BY-SA 4.0 · citation page · JSON