Names and Scoping Flashcards

1
Q

What is a name in the context of FMAL?

A

Identifiers for objects existing during the execution of a program

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

What is Environment?

A

The set of associations between names and denotable objects which exist at runtime at a specific program point and specific time during the execution

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

What is a block?

A

A textual region identified by some start and end signs, which can contain declarations local to that region.

Can be nested

Can be associated with a procedure(procedure bodies) and in-line blocks

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

Describe local, non-local and global associations of the environment

A

Local: associations of the current block

non-local: Those of the encompassing blocks

global: Those of the outermost block

A declaration in a block is visible in the block and all nested blocks unless there is a new declaration of the name in a nested block

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

There are five operations possible on associations with names in the environment

A
  1. Create an association when entering a block declaring the name
  2. Dereference (access the denotable object by name) inside this block
  3. Deactivate an association when entering a block where a new association for the name is created locally
  4. Reactivate an association when leaving this block
  5. Destroy an association when leaving the block declaring the name
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

There are four operations possible on denotable objects

A
  1. Create
  2. Access
  3. Modify
  4. Destroy

note: The lifetime of a denotable object can be longer than that of an associated name.

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

Describe static scope

A

The valid association for a name x at a point p of a program is the nearest association created for x by a declaration in the block where p belongs or an enclosing block. REMEMBER point p MOVES to a function when the function is called!!!

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

Describe dynamic scope

A

The valid association for a name x at a point p of a program is the most recent association created for x that is active at the particular time that control reaches p.

Think… function replaces the call of the function.

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