CSE 130: Principles of Programming Languages
Midterm Examination, 17 February 2004

You should write answers in a blue book, but this paper could be used if you do not have a blue book.
Be sure to write your name on every sheet you hand in!
  1. [18pts] After each phrase write the letter of the definition that most closely matches its meaning in this course.

    phrase answer definition
    1. invariant   a. determine sizes for storage needed
    2. spaghetti code   b. determine locations for storage
    3. coercion   c. declaration of a variable
    4. layout   d. variable with undefined value
    5. variant record   e. invisible type conversion
    6. dereference   f. subtype relationship
    7. garbage   g. structure with multiple layouts
    8. binding occurrence   h. storage that is no longer needed
    9. assign   i. leave a loop
        j. re-enter a loop
        k. find the value in a cell
        l. find the pointer to a cell
        m. punctuation for items in a list
        n. code that does not work
        o. property of variables true inside a loop
        p. code with many goto's
        q. change the value of a variable
        r. resume execution of a procedure

  2. [14pts] The XML Schema below defines types "feet" and "miles", and elements "height" and "distance" of those types ("xs:" indicates XML Schema world). For this case, explain the difference between name and structural equivalence, and a possible confusion that could arise. <xs:simpleType name="feet"> <xs:restriction base="xs:integer"/> </xs:element name="height" type="feet"/> <xs:simpleType name="miles"> <xs:restriction base="xs:integer"/> </xs:element name="distance" type="miles"/>
  3. [14pts] Match each name in the first list with the name or names in the second list that best fit it.
  4. [15pts] What major new features did Algol60 provide, in comparison with Fortran? What was the motivation for introducing those features?
     
  5. [20pts] Draw a parse tree for the string "time flies like an arrow" in the following BNF grammar: S ::= NP VP NP ::= N | Det N VP ::= V | V PP PP ::= P NP N ::= time | arrow V ::= flies Det ::= an | the P ::= like Now add to the grammar so that the same sentence has another parse where "time flies" is an NP, noting that "flies" is also a noun, the plural form of "fly" (the insect), and that clusters of nouns can be noun phrases in English. Draw a tree for the second parse.
     
  6. [19pts] Expain the difference between lexical and dynamic scope for variables in a programming language; base your discussion on an example that illustrates the difference.

To CSE 130 homepage
Maintained by Joseph Goguen
© 2004 Joseph Goguen