Machine-translated by Google. Questions are authored in English.
Top

Discussion

Arrange the actions taken when a compiler enters and leaves a nested block.
1. resolve uses within the block against the scope chain
2. create or push a new scope on entering the block
3. discard or pop the scope on leaving the block
4. install the declarations found in the block into that scope

  • A.4 - 2 - 1 - 3
  • B.2 - 1 - 4 - 3
  • C.2 - 4 - 1 - 3
  • D.3 - 1 - 4 - 2

Answer: C

Correct answer: 2 - 4 - 1 - 3

The scope must exist before anything can be installed in it, and the declarations must be installed before uses can be resolved against them. Discarding comes last, when the block ends and its names go out of scope. Resolving before installing would fail on any name declared in the block itself.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.