Thu Oct 20 21:13:01 EDT 2011


Still quite some floating around, but at least there are two useful
advancements.  See also [1].

 - Syntax ADT for modified ANF/CPS form for state-machine language.

   Basic idea: if there are only tail-recursive calls, then function
   calls are set+goto, so loops can be functions.  This means that
   there is no need for special imperative representation which should
   keep it simpler.

 - Simple C correspondence.

   The interesting part is that lexical scope still works for variable
   bindings, i.e. ANF form can be implemented directly in C if there
   are only primitive operations (which is the whole idea: everything
   is inlined for speed).

type Opc  = String
type Val  = String

data Fun  = Fun String
            deriving (Show, Eq)

data Var  = Var String
            deriving (Show, Eq)

data DefVar = DefVar Var Prim 
            deriving (Show, Eq)
data DefFun = DefFun Fun [Var] Expr
            deriving (Show, Eq)
data Prim = Lit Val
          | Op  Opc [Var]
          | Ref Var
          deriving (Show, Eq)
data Expr = Let    [DefVar] Expr
          | LetRec [DefFun] Expr
          | If     Var Expr Expr
          | Call   Fun [Var]
          deriving (Show, Eq)

[1] entry://20111020-135041