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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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-...
View Full Document

This note was uploaded on 10/13/2009 for the course CS 3773 taught by Professor Staff during the Spring '08 term at The University of Texas at San Antonio- San Antonio.

Ask a homework question - tutors are online