[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Aspect Oriented Programming in context of lightweight languages.



John Clements wrote:

> WANTED: certified call/cc operator.  experience a plus.
> 
> 
> john "interested parties please submit continuation to..." clements

(define (make-box val)
  (letrec ((slot (call/cc (lambda (k) k))))
    (if (pair? slot)
        ((cdr slot))
        (let* ((setter slot)
               (box (lambda new-val
                      (if (null? new-val)
                          (if (pair? slot) 
                              (car slot))
                          (call/cc
                           (lambda (k)
                             (setter (cons (car new-val) k))))))))
          (box val)
          box))))

(define (box-ref b) (b))
(define (box-set! b x) (b x))


Do I get the job?