Re: Continuations and dynamic variables



Talking to myself, but anyway...

What I meant was the whole dynamic binding structures are lost, of
course.

Using conditions for example:

(require :cl-cont)

(use-package :cl-cont)

(define-condition unhandled-condition (error)
())

(defvar *cont*)

(with-call/cc
(handler-case
(progn
(call/cc (lambda (cont)
(setf *cont* cont)))
(error 'unhandled-condition))
(unhandled-condition () (print "Condition handled!"))))

(funcall *cont*)

That signals a condition that doesn't get caught. I know that's
because when we do (funcall *cont*) we are in a different dynamic
environment.

Just wonder which is the correct semantic, and whether it is possible
to implement something that executes the continuation in the dynamic
environment it was generated somehow.

Btw, the continuation library seems to be buggy, so my experiments may
mean nothing:

This doesn't handle the condition, although I think it should:

(with-call/cc
(handler-case
(error 'unhandled-condition)
(unhandled-condition () (print "Condition handled!"))))

Mariano

On 20 mar, 17:23, Mariano Montone <marianomont...@xxxxxxxxx> wrote:
Hello,
          I'd like to know how dynamic variables are supposed to
behave when using continuations. The way to implement continuations in
CL is by code transformation where the lambdas generated represent the
rest of the computation. The problem I see with this is that dynamic
variable bindings are not preserved.

For example, using the cl-cont package that works like that:

(require :cl-cont)

(use-package :cl-cont)

(defvar *my-dyn-var*)

(defvar *cont*)

(with-call/cc
  (let
      ((*my-dyn-var* "hello!!"))
    (call/cc (lambda (cont)
               (setf *cont* cont)))
    (print *my-dyn-var*)))

(funcall *cont*)

That prints nil instead of hello!! (the dynamic variable binding is
lost).

So, which is the correct semantic??

If our language were interpreted and we had access to the stack-
frames, we could get rid of the code transformation and implement
continuations copying stack-frames instead. This way, dynamic variable
bindings are preserved, which is interesting for programming some web
applications. AFAIK, this is how Seaside implement them, so I guess
they don't have that problem.

Thoughts?

Thanks!

Mariano

.



Relevant Pages

  • Re: This seems slow...Why???
    ... sure that there is no binding involved. ... but I have since cleared all of the data binding properties ... so not sure if I'm completely lost ... > Regardless, even if I had bound my controls, this seems incredibly slow to ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How would you do this in forth?
    ... try continuations: ... gives you normal Forth binding, ...
    (comp.lang.forth)
  • Re: Trouble with Lisp interpreter (written in Scheme)
    ... I don't undestand why you are trying to use continuations here. ... returns binding of x in environment n, ... (lambda (f a k) ...
    (comp.lang.scheme)
  • Re: Need Help Please!
    ... is there any body out there that could help me on this just lost like ... over a week trying to make this work realy going crazy with this ... > ok here's the code and bellow i explain the problem ... but when i had the blank row before binding the ...
    (microsoft.public.dotnet.framework.aspnet.datagridcontrol)
  • gutter in 2 page spread
    ... We would like to put images on a two page spread. ... But some will be lost ... in the middle due to the binding of the booklet. ...
    (microsoft.public.publisher)