[<<][staapl][>>][..]
Fri Apr 24 20:44:03 CEST 2009

the new scat

So.. What is a stack language?  It's like a functional language where
the environment is replaced with an explicit stack.



ok, it went fast for a bit.. trying this now:

(define-syntax-rule (op-2->1 op)
  (lambda (d r)
    ((car r) ;; call continuation
     (cons (+ (car d)
              (cadr d))
           (cddr d))
     (cdr r))))

(define (done) (list (lambda (d r) d)))
(define-syntax-rule (run program stack)
  ((ns (rpn) program) stack (done)))

Basicly, each fn takes 2 arguments, the data stack and the
continuation stack.  It performs a primitive computation and passes
the (d r) to the popped continuation.

Next step is to define a parser, basicly an expansion time
interpreter.  This will lead us to something very close to the CEK
machine.

(lambda (d r c) ...)

p : parameter stack
r : continuation stack (return stack)
c : code stack
d : dictionary


the p and r can be eliminated during parsing.. probably re-introduced
later.

the continuation stack can be abstracted as a procedure. it never
needs to be implemented as a stack.

it might also be faster to run functions from a list than to construct
syntax for them.



DAMN..
almost there, but i'm fading out..

i'm confused about the tension of implementing the contuations as an
explicit stack, or as an abstract function.

for functions, i need to figure out how to write "compose"

(define (a p k) ...)
(define (b p k) ...)

(compose (a b)
  (lambda (p k1)
    (a p (lambda (p k2) (b p k1)))))


Now, how does a primitive look?

(define-syntax-rule (op-2->1 op)
  (lambda (p k)
    (k (cons
        (op (p-car p)
            (p-cadr p))
        (p-cddr p)))))




[Reply][About]
[<<][staapl][>>][..]