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

Re: [Scheme-reports] About the behavior of continuation in top-level begin form



Looks like the same as (values) to me.   Is there any reason why this might not be the case?
=========
Can't agree more.

I don't think that the problem I talked before have any relation with REPL. Please tell me if I am wrong. I just simplified the example to make it clearer, it could have been more complex like: 

Snippet A:
(define cc #f)

(define (complex-judgement) #t)
(define (do-complex-things) "Do complex things and return a string.\n")

(begin (cond ((complex-judgement) (call/cc (lambda(k) (set! cc k)))))  (display (do-complex-things)) )
(cond (cc (cc)))

Snippet B:
(define cc #f)

(define (complex-judgement) #t)
(define (do-complex-things) "Do complex things and return a string.\n")

((lambda () (cond ((complex-judgement) (call/cc (lambda(k) (set! cc k)))))  (display (do-complex-things)) ))
(cond (cc (cc)))


Snippet C:
(define cc #f)

(define (complex-judgement) #t)
(define (do-complex-things) "Do complex things and return a string.\n")

(cond ((complex-judgement) (call/cc (lambda(k) (set! cc k)))))
(display (do-complex-things))
(cond (cc (cc)))

you can compile all these programs, you can add things to complex-judgement(maybe read an setting file, anything), and you can make do-complex-things do really complex things, but it doesn't matter.

I just wonder why B&C have an clear behavior, while A have an ambiguous behavior.
It seems inconsistent to me. Maybe the behavior should be specified? What do you think of it?





2013/4/18 Jim Rees <jimreesma@x>
On Wed, Apr 17, 2013 at 9:21 PM, John Cowan <cowan@x> wrote:
張書瀚 scripsit:

> But the problem of begin, as I said before, is still there.  I don't
> think it's good to deliberately leave that behavior unspecified
> in the standard, so I post it here (for me, it creates unnecessary
> misunderstandings).

It's a hard problem.  Suppose you are using a Scheme system like Chicken
or Gambit, that compiles Scheme code to stand-alone executables.  What do
you expect this to do?

(call/cc (lambda (x) (x)))

Looks like the same as (values) to me.   Is there any reason why this might not be the case?

I just tested this on Chicken, and it works as expected -- both using the csi repl, and in a compiled program.

But, in general, I do agree that capturing a continuation and re-executing it through REPL code shouldn't be relied upon to behave in any predictable way.
 

There just isn't any good answer, because the captured continuation is
outside Scheme.  Likewise, if you run something like this from a REPL,
you are capturing a continuation in the REPL's own code, which may or
may not be in Scheme.

Such issues are inherently outside the scope of any Scheme standard.

--
John Cowan   cowan@x    http://ccil.org/~cowan
You cannot enter here.  Go back to the abyss prepared for you!  Go back!
Fall into the nothingness that awaits you and your Master.  Go! --Gandalf


_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports