Lecture 4 Flashcards
What is a type?
Set of values together with a set of operations on these values.
Example:
Integers: integer numbers + add, sub, div, mul
What is static type checking?
Performed before execution, at compile-time
What is dynamic type checking?
Run-time type checking.
Performed during execution, before execution of each individual operation.
How is a practical language defined from the kernel language?
Add syntactic sugar and linguistic abstractions.
Syntactic sugar: Syntactic conveniences for commonly used functionality.
Linguistic abstractions: Syntactic conveniences that introduce new programming structures without extending the model of computation.
Give 2 examples of syntactic sugar
Nested records:
Z = z(y: y(x: 1))
Multiple variable declaration:
local X Y Z in <s> end</s>
How can record features be accessed using pattern matching?
case E of label(feature2: value anotherFeature: value4) then
X = value
Y = value4
end
What does _ mean in:
case R of label(f1:_ f2:value) then
(‘_’) denotes an unnamed variable, used to keep values we do not care about.
What syntactic sugar makes it easier to access record fields?
A = recordName(feature: value)
X = A.feature
What does Record.arity return?
List of features
What is a keyword?
A lexeme that has some special meaning, may be related to syntactic and semantic rules
What are reserved words?
Lexems that can only be used as keywords.
What is an atom?
Atom start with lowercase, and any variables/symbols after that
Atom can be any lexem in quotes matching ‘[^`\]’
A record with no fields:
atom == atom()
Syntactically, atom is not equivalent to atom()
What is an identifier?
A syntactic entity, part of programs sequence of tokens
Identifier mapped to variable.
Variable bound to value.
What is a variable?
A semantic entity, part of the execution of a program.
What are declarative variables?
After initial binding, they cannot be reassigned another value.
Dataflow variables.