Worked out cbneed-smallstep.
Worked out cbneed-smallstep.

I think cbneed-smallstep.dd is in a final and good place.

Points from the meeting today with DVH:

- Use (or start with) the AAM'd Krivine machine from the ICFP 2010 AAM
  paper.
- Use program locations for allocating addresses at runtime (when there
  is no binder to user).
- The CBNeed semantics in the AAM paper:
  - Treats the control expression as something that needs to be forced
  - Has a stack (continuation) to encode the demand context
- The "double stack" semantics I had sketched was a little strange.
- CPS is unnecessary in CBNeed

Where I ended up:

- I reached the conclusion that CPS _is_ helpful in CBNeed
  - The semantics in the paper doesn't have let-expressions,
    case-expressions, or primitive operations. These give rise to the
    "stupid" machine transitions that CPS eliminates.
- It's true that the CPS rule I had for function calls was not useful.
  - The right thing to do is to CPS convert function calls |CPS(e1 e2)|
    into |LET x := THUNK(e1,e2) IN <continue>(x)|. This way the
    immediate work to be done upon seeing a function call is atomic, and
    the CPS transformation is now encoding the stack I was looking for.
- I now use the control expression as something that needs to be forced,
  as borrowed from the Krivine machine.
- I'm generating two binder names for each thunk at CPS time: one for
  the name to bind the continuation when calling the function, and one
  for the name to bind the argument when returning to the call as a
  forcing context.
- Where I ended up, I claim, is exactly what you'd get if you beefed up
  the Krivine machine from the ICFP 2010 AAM paper with the added
  features (let,letrec,case,+,etc.) and then imposed a systematic CPS
  discipline.

FranklinChen/maam,davdar/maam