[Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread Ricardo Gabriel Herdt
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! c

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread felix . winkelmann
> 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? You are re-entering the execution of "map" by calling the stored continuation, which was at tha

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread Ricardo Gabriel Herdt
Am 19.10.2019 14:18 schrieb felix.winkelm...@bevuta.com: The exact behaviour of re- entering a continuation captured during execution of "map" is, I think, dependent on implementation details (there may be a note about this in the SRFI-1 document or R7RS, I can't remember right now). Many tha

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread megane
Ricardo Gabriel Herdt writes: > Am 19.10.2019 14:18 schrieb felix.winkelm...@bevuta.com: >> The exact behaviour of re- >> entering a continuation captured during execution of "map" is, I think, >> dependent on implementation details (there may be a note about this in >> the >> SRFI-1 document o

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread Ricardo Gabriel Herdt
Am 19.10.2019 15:46 schrieb megane: There's special compiler syntax for map; search for 'map-loop in the sources. You can also see what your code expands to by giving -debug 2 flag to csc. Thanks megane, with -debug 2 I see that map uses some local variables that are changed with set! in the

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread felix . winkelmann
> I found this in R5RS/R7RS/SRFI-1: "The dynamic order in which proc is > applied to the elements of the lists is unspecified". Indeed redefining > map in all implementations as > > (define (map f l) >(cond ((null? l) '()) > (else (cons (f (car l)) > (map f (cdr l)) > > make all be

Re: [Chicken-users] continuation example: different behavior from other Scheme implementations

2019-10-19 Thread Ricardo Gabriel Herdt
Am 19.10.2019 18:57 schrieb felix.winkelm...@bevuta.com: But what I forgot, and which may be the confusing part is that after the mapping is complete, "numbers" (in your example) will be assigned once again - the continuation includes everything following the invocation of "map". Only the REPL