What does “legal” mean in programming?

0
7
Asked By MellowKite27 On

When programmers say that a character is "illegal" or that overriding a method in a certain way is "legal," what exactly do they mean? Does it simply mean that the programming language allows or disallows it, and what happens if I use something that isn't allowed?

3 Answers

Answered By PixelHarbor8 On

“Legal” just means permitted by the rules of the programming language. An “illegal character” is one that isn’t allowed in that particular location, while a legal method override follows the language’s rules. If you break those rules, the compiler or interpreter usually reports an error, and the program may not compile or run correctly.

Answered By OrbitMango6 On

Sometimes people use “legal” specifically to mean syntactically valid: the code is written in a form the language recognizes. Invalid syntax is commonly caught before the program runs, although some rule violations may only appear during execution depending on the language.

Answered By CedarFox41 On

Think of it like chess or basketball. Moving a knight in a straight line is an illegal chess move because it violates the game’s rules. Similarly, code can be illegal when it breaks the syntax or rules defined by the language. Nothing criminal is involved—it’s just a technical way to say “not allowed.”

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.