Programming Languages - Exam 1 Review Questions | CS 3723, Exams of Programming Languages

Material Type: Exam; Professor: Yi; Class: Programming Languages; Subject: Computer Science; University: University of Texas - San Antonio; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 07/30/2009

koofers-user-u61
koofers-user-u61 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CS3723 Midterm Exam 1 Review Questions
1. Concepts
(a) Give three key differences between the ML and Scheme languages
(e.g., interpretation vs. compilation, dynamic vs. static typing).
(b) What is the difference between regular ML variables and C variables?
What is the difference between ML reference cells and C pointers?
(c) What is a type? What are types used for in the design and imple-
mentation of programming languages?
(d) What is a basic type? What is a compound type? Give three exam-
ples of each.
(e) What is a type declaration? What is the difference between a trans-
parent and an opaque type declaration?
(f) What are the different ways to determine whether two types are
equivalent? Give two example types for each method of type equiv-
alence.
(g) What is a type system? What components does it include?
(h) What is a type error? What is the requirement for a language to be
type safe? Give an example code in C that has a type error. Is C
type-safe? Why or why not? Give two languages that are type safe.
(i) What is type checking? What is the difference between compile-time
and runtime type-checking? What is the difference between compile-
time type checking and type inference? What are the tradeoffs be-
tween compile-time vs. runtime type checking.
(j) What is polymorphism? What are the different kinds of polymor-
phism a language may support? Give an example code in Scheme/ML
for each kind of polymorphism respectively.
(k) What is a block? What needs to be done to manage its memory?
(l) What is an inline block? Give an example inline block in C,Scheme,ML.
What is the format of its activation record?
(m) What is a function block? What is the format of its activation record?
Which link (address) does the block need to follow to find its caller?
What is the difference between static and dynamic scoping in looking
for global variables? Which link (address) does the block need to
follow to find global variables using each scoping rule?
1
pf2

Partial preview of the text

Download Programming Languages - Exam 1 Review Questions | CS 3723 and more Exams Programming Languages in PDF only on Docsity!

CS3723 Midterm Exam 1 Review Questions

  1. Concepts

(a) Give three key differences between the ML and Scheme languages (e.g., interpretation vs. compilation, dynamic vs. static typing). (b) What is the difference between regular ML variables and C variables? What is the difference between ML reference cells and C pointers? (c) What is a type? What are types used for in the design and imple- mentation of programming languages? (d) What is a basic type? What is a compound type? Give three exam- ples of each. (e) What is a type declaration? What is the difference between a trans- parent and an opaque type declaration? (f) What are the different ways to determine whether two types are equivalent? Give two example types for each method of type equiv- alence. (g) What is a type system? What components does it include? (h) What is a type error? What is the requirement for a language to be type safe? Give an example code in C that has a type error. Is C type-safe? Why or why not? Give two languages that are type safe. (i) What is type checking? What is the difference between compile-time and runtime type-checking? What is the difference between compile- time type checking and type inference? What are the tradeoffs be- tween compile-time vs. runtime type checking. (j) What is polymorphism? What are the different kinds of polymor- phism a language may support? Give an example code in Scheme/ML for each kind of polymorphism respectively. (k) What is a block? What needs to be done to manage its memory? (l) What is an inline block? Give an example inline block in C,Scheme,ML. What is the format of its activation record? (m) What is a function block? What is the format of its activation record? Which link (address) does the block need to follow to find its caller? What is the difference between static and dynamic scoping in looking for global variables? Which link (address) does the block need to follow to find global variables using each scoping rule?

(n) What components does the runtime memory model of a program include? List 4 of these components and briefly explain each. (o) In order to locate the storage of variables at runtime, what part of the variable address is precomputed by the compiler? Which part is dynamically looked up at runtime? What is the value of a function? (closure). What are the components of the function closure? (p) Give three different ways of parameter passing? Briefly explain each. Given an example where each method of parameter passing is used. What is the difference between the pass-by-reference in Java and pass-by-pointer in C? (q) If functions are allowed to be returned as values in a language, what additional support for the runtime stack must be implemented by the language? In another word, why doesn’t C/C++/Java support returning functions as results? (r) What is a tail call? What is tail recursion? Why is tail recursion equivalent to loops? (s) What is an exception? What does it do? What can it be used for? What is different between exception and a regular goto jump? What is required from a language to support exception? (t) When looking for exception handlers, do we use static scoping or dynamic scoping? Why? (u) What is a continuation? What can it be used for?

  1. Exercises

(a) Translate Scheme code to ML. (b) Apply type inference to determine the types of variables in ML code. (c) Draw the snapshot of runtime stack for ML code. (d) Convert tail recursive functions to loops in ML (e) Convert ML code to continuation passing style. (f) List the sequence occured events when a ML code with exceptions is evaluated.