Programming Languages and Compilers

 

Lecture 7

 

In this lecture we will look a bit more at types and data encapsulation.

 

The slides for this lecture can be found here.

 

Literature

 

Pratt and Zelkowitz, chapter 5 and chapter 6.

 

Exercises

 

Exercises for lecture 7 will be done from 8.15 till 10.00 before Lecture 8 on Wednesday the 9th of April.

 

  1. Do Pratt and Zelkowitz exercise 5.6.1 on page 196. Consider the languages SML, C and Java. What about the language you are designing?
  2. Do Pratt and Zelkowitz exercise 5.6.5 on page 196. Consider the languages SML, C, Java and Perl or JavaScript. Look e.g. at arrays, access to pointers/references and division by 0. Are there other constructs you can think of? What about the language you are designing?
  3. Do Pratt and Zelkowitz exercise 5.6.8 on page 197. Sketch the implementation in pseudo code or write in C or simulate bytes and words as arrays in Java or SML.
  4. Do Pratt and Zelkowitz exercise 5.6.12 on page 198. Consider SML, C and Java. What about the language you are designing?
  5. Do Pratt and Zelkowitz exercise 6.7.3 on page 257.
  6. Do Pratt and Zelkowitz exercise 6.7.5 on page 257. SML doesn’t allow arrays of mixed data types, but still use a similar implementation as described for SIMSCRIPT, can you explain why?
  7. Do Pratt and Zelkowitz exercise 6.7.15 on page 259. Consider again C, SML, Java and Perl or JavaScript. What about the language you are designing?
  8. Do Pratt and Zelkowitz exercise 6.7.21 on page 260. Will constructs like ord be necessary in the language you are designing?