Lecture 4 Flashcards

1
Q

What is a type?

A

Set of values together with a set of operations on these values.

Example:
Integers: integer numbers + add, sub, div, mul

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is static type checking?

A

Performed before execution, at compile-time

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is dynamic type checking?

A

Run-time type checking.

Performed during execution, before execution of each individual operation.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How is a practical language defined from the kernel language?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Give 2 examples of syntactic sugar

A

Nested records:
Z = z(y: y(x: 1))

Multiple variable declaration:
local X Y Z in <s> end</s>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How can record features be accessed using pattern matching?

A

case E of label(feature2: value anotherFeature: value4) then
X = value
Y = value4
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What does _ mean in:
case R of label(f1:_ f2:value) then

A

(‘_’) denotes an unnamed variable, used to keep values we do not care about.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What syntactic sugar makes it easier to access record fields?

A

A = recordName(feature: value)

X = A.feature

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does Record.arity return?

A

List of features

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a keyword?

A

A lexeme that has some special meaning, may be related to syntactic and semantic rules

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are reserved words?

A

Lexems that can only be used as keywords.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an atom?

A

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()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is an identifier?

A

A syntactic entity, part of programs sequence of tokens

Identifier mapped to variable.
Variable bound to value.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a variable?

A

A semantic entity, part of the execution of a program.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are declarative variables?

A

After initial binding, they cannot be reassigned another value.

Dataflow variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are partial values?

A

Can contain unbound variables, e.g. records.

declare X Y in
Y = label(feature: X)

17
Q

Why does Browse not belong to the declarative sequential model of computation?

A

It starts a new thread in which the browser displays a value

18
Q

What is an expression?

A

An operation that evaluates to a value.

Examples:
2+2 (evaluates to 4)
A == B (evaluates to true or false)
proc {$ X} X = 1 end (evaluates to a procedure)

19
Q

What is a statement?

A

Specifies an operation that does not evaluate to a value.

X=1 (unifies X with 1)
{Browse ‘hello’}
skip

20
Q

Define a program in the declarative sequential kernel language in regards to statements and expressions

A

A program composed exclusively of statements

21
Q

Give an example of if-else constructs being a statement and an expression

A

Statement:
local X in
if A > B then
X=A
end
end

Expression:
if A > B then
A
end

22
Q

What is a function?

A

Linguistic abstractions of procedures.

A function definition can be translated into a procedure.

Function of n arguments is a procedure of n + 1

23
Q

What does # mean?

A

It is the tupling constructor.

Syntactic sugar for building records.

X#Y#Z equals ‘#’(X Y Z)

Instead of X == 1 andthen X==2 andthen X== 3 then <s> end</s>

We can pattern match:
case X#Y#Z of 1#2#3 then <s> end</s>

24
Q

What is a list?

A

A sequence of records.

The record that form a list has the label ‘|’ and 2 features (1: Head and 2: Holds tail list)

[one two]
= ‘|’ (one ‘|’ (two nil))
= one|two|nil

25
Q

What is the arity of a(c: 1 b:2) and a(c b)

A

A = a(c: 1 b:2)
B = a(c b)

A.arity: [b c]
B.arity: [1 2]

Arity returns sorted list

26
Q

What does the pattern H|_ mean?

A

’|’ (1: H 2:_)

Feature 2 can contain whatever value