Thu Apr 4 19:48:41 EDT 2013

hold and setup

One of the features I'm looking for is `hold', which computes an
expression once at t=0, then holds that value.

The other one is `setup' which takes the first expression at t=0 and
the second one otherwise.

(define (test-subsample (s) (x))
      ((s (setup (+ s 1) s))
       (y (hold x))))
    (+ s x y)))

The thing is that these mechanisms are distinct, but they are unified
in the "setup/update" 2-phase approach.  This seems to be the cause of
a lot of confusion.

An advantage of implementing them separately is that we can unroll the
loop for t=0 and t>0 and just directly implement the 2 behaviors
without resorting to assignments, just variable shadowing.

setup: t=0 / t>0 each take one of the branches. practically, every prim can be tagged.
hold:  first unroll defines the variable, second unroll doesn't define the variable.

Now, by defining (hold x) as (setup x #f) this might be implemented
using a single mechanism.  So let's start with setup.

Capturing the bindings seems to be simple.  However, it might be
better to implement this as a type-annotation, since it's a bit
special anyway.

Think about it a bit..

Looks like there is a solution.  This can be implemented using an
explicit "p_phase" primitive which performs an actual (t==0)
comparison.  However, using proper annotation generated during AI, the
nodes can be tagged to be left out of one of the 2 phases: setup (t=0)
and loop (t>0).

Trouble is that "hold" doesn't work this way: it needs explicit support.

The rest is for later.
It's a big change, but looks straightforward.