{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

midterm2-sol - CS3723 Midterm Exam 2 Solution for concept...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
CS3723 Midterm Exam 2 Solution for concept questions 1. (30pts) Finish the following sentences by filling in the blanks. (a) In programming languages, a block is a region of code that introduces new variables . Blocks can be nested inside each other but not overlapped with each other. An example of a block in Scheme is (let ((x 2)) x) ; An example of a block in ML is fun foo(x) = x; . (b) When programs are loaded to memory to be evaluated, its memory space can be separated into three components, the code space , which contains the program/instructions to be evaluated ; the runtime stack , which contains storages for all local variables ; and the heap , which contains dynamically allocated storages . (c) The scoping rule of a programming language defines where to look for the scope of (i.e., the block that declares) non-local variables at runtime. If static scoping is used, we find the scope of a non- local variable by looking in the blocks that contain the current one ; in contrast, if dynamic scop-
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online