What does “legal” mean in programming?

0
0
Asked By MellowPine42 On

When programmers say that a character is illegal or that a particular way of overriding a method is legal, what exactly do they mean? Does "illegal" simply mean the programming language does not allow it, or can it refer to something else?

3 Answers

Answered By PixelHarbor7 On

In programming, “legal” usually means permitted by the rules of the language. An illegal character, statement, or method override violates those rules, so the compiler or interpreter may reject it, or the program may fail when it runs. There are no actual legal consequences—it’s just terminology borrowed from everyday language.

Answered By CedarOrbit5 On

People sometimes use “legal” to mean syntactically valid, meaning the code follows the language’s grammar and can be parsed or compiled. Other times they mean that an operation is allowed by the language’s semantics or type system. In either case, “illegal” generally means the language tools reject it or it does not behave as a permitted operation.

Answered By QuietFalcon_8 On

It’s similar to calling an incorrect move in chess “illegal.” A knight moving in a straight line breaks the rules of chess; likewise, code is illegal when it breaks the syntax or rules defined by the programming language. For example, using an unsupported character in an identifier or overriding a method with an incompatible signature may be rejected.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.