[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] continuation example: different behavior from other Sche
From: |
Ricardo Gabriel Herdt |
Subject: |
[Chicken-users] continuation example: different behavior from other Scheme implementations |
Date: |
Sat, 19 Oct 2019 12:55:07 +0200 |
User-agent: |
Posteo Webmail |
Hi all,
I'm trying to understand how continuations work, and tried out the first
example described at
"https://en.wikibooks.org/wiki/Scheme_Programming/Continuations" with
Chicken (5.1):
-----------------------------------------------
(define continuations '())
(define (push arg)
(set! continuations
(cons arg continuations)))
(define (capture-from-map arg)
(call-with-current-continuation
(lambda (cc)
(push cc)
arg)))
(define numbers (map capture-from-map '(1 2 3 4 5 6)))
;;REPL
numbers
(1 2 3 4 5 6)
((car (reverse continuations)) 76)
((result "#<unspecified>") (output . ""))
numbers
(1 2 3 4 5 6 76 2 3 4 5 6)
-----------------------------------------------
To my surprise, this last value stored at 'numbers' differs from other
implementations (and from the example described on the Wiki):
Guile/Racket/MIT: (76 2 3 4 5 6)
Chez: (1 2 3 4 76 6)
Could someone please explain what's going on? Why would Chicken append
the new list to the old value of 'numbers', which as I understand should
be empty at the moment of the stored continuation?
Regards,
Ricardo
- [Chicken-users] continuation example: different behavior from other Scheme implementations,
Ricardo Gabriel Herdt <=