What is semantics?
The meaning of programs; how the language constructs actually behave when executed.
What is the purpose of semantic analysis?
To check whether the program makes sense beyond syntax—types, declarations, scopes, returns, etc.
What is static semantics?
Rules checked at compile time (types, variable declarations, scope, returns, etc.).
What is dynamic semantics?
The meaning of program execution—what happens when the program runs.
What is a semantic error?
A program that is syntactically correct but makes no sense (e.g., adding a number to a string).
What is a data type?
A category of values (int, float, bool) defining what operations are allowed.
What is type checking?
The compiler verifies expressions use types correctly (e.g., cannot add a bool to a string).
What is strong typing?
A language that prevents mixing incompatible types—errors are caught early.
What is weak typing?
A language that allows more type conversions, sometimes unsafely.
What is type inference?
The compiler figures out the type for you automatically, without explicit type declarations.
What is a coercion?
An automatic type conversion performed by the compiler (e.g., int → float).
What is a cast?
A manual type conversion written by the programmer.
What is scope?
The region of a program where a variable or identifier is visible and accessible.
What is static (lexical) scoping?
The scope of a variable is determined by where it appears in the source code,
❌ NOT by the order in which functions are called at runtime.
What is dynamic scoping?
A variable’s scope depends on the calling sequence at runtime.
What is a binding?
An association between a name and something else (type, value, location).
What is a binding time?
The time when a binding is created (compile time, run time, link time, etc.).
What is a declaration?
A statement that introduces a name and often its type.
What is a definition?
A declaration that also allocates storage or provides a value.
What is a symbol table?
A structure the compiler uses to track identifiers, their types, scope, and bindings.
What is an L-value?
variable on the left side
stands for a location
What is an r-value?
A value produced by an expression (the right side of an assignment).
What is an l-value vs r-value example?
In x = y + 2, x is an l-value (location), y+2 is an r-value (value).
What is a side effect?
An action besides returning a value (e.g., modifying a variable or printing).