Tue Jun 5 18:44:57 EDT 2012

Dynamic binding

While I don't really like dynamic binding so much, in forth it can
sometimes be quite handy.  Especially for streams it seems.

The overhead of local (stack) variables is too high.  In Chuck Moore's
stack machines, there is also a current pointer register.  For Staapl
on PIC there is already a & f so might be good to abstract it a bit.

However, moving bytes around is about the only thing we are ever going
to do a lot of so let's just define i> >o and use dynamic binding to
point them to current input and current output, with values saved on

what about this:

  iopen-<xxx>  connects something to i> and performs init
  iclose       calls close method + pops previous input

nope open/close should be different from `parameterize'.

  i-begin      pushes old i> vector to RS and installs new one
  i-end        pops old i> vector

So it seems best to do this on top of a vector abstraction.  There
really aren't so many tokens to manage, so sticking to bytes seems the
best approach.  The token table can be defined in the monitor, or

Previous code used 128 tokens (even ones not used) all stored at first
ram bank.

: do-arrow
    0 a!!
    TOSL @ !a+
    TOSH @ !a+
    pop ;

Actually there seems to be a simpler way to do this, which is to place
the indirection at the hardcoded level: reserve flash space for
vectors.  In the config .fm it could be defined where to put it.  I'm
wondering if it's possible to do some kind of smart ' (tick) operator:
automatically generate tokens whenever a tick is encountered.

TRAP.  This is a trap.  Just define a global execute function with a route

: e0 0 ;
: e1 1 ;
: e2 2 ;
: execute _e0 . _e1 . _e2 ; 

Hmmm..  Trouble really is that global and incremental compilation are
really different.  Unless we use a linked list approach.

TRAP.  It's a trap!

What I need is a way to make some global "gather" compilations work.
It should be no big deal in the all-at-once module compiler, but doing
this incrementally is problematic, unless there is a way to make the
gathering operations updateable.

I think the state machine stuff works here too.  Also, the code
instantiation should be able to use it.

Anyway, this is a deep hole.