Class 24: Modern PL Features: generics, generators, and scripting


Display version (pdf).




  1. Briefly describe what we would have to do to get generators into our SPL interpreter. Assume that for-each loops have already been implemented; I mostly want to know what the data structure for storing a generator would look like in the SPL interpreter.
  2. Consider the following very simple class definition in Java:
    public class AClass<T> {
      T x;
      AClass() { x = new T(); }
    What error does javac give if you try to compile this class? What specifically is not allowed, and why?