unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* call/cc does not return a value
@ 2024-09-13  6:52 Damien Mattei
  2024-09-13  8:25 ` Mikael Djurfeldt
  0 siblings, 1 reply; 5+ messages in thread
From: Damien Mattei @ 2024-09-13  6:52 UTC (permalink / raw)
  To: guile-user

hello,

i believed call/cc allowed to return value but i have this macro and i can
use continuation, but the value is not passed to the continuation:

(define-syntax for
   (lambda (stx)
     (syntax-case stx ()
       ((kwd (init test incrmt) body ...)

        (with-syntax ((BREAK (datum->syntax (syntax kwd) 'break))
                      (CONTINUE (datum->syntax (syntax kwd) 'continue)))

    (syntax
     (call/cc
      (lambda (escape)
(let-syntax ((BREAK (identifier-syntax (escape))))
  init
  (let loop ()
    (when test
      (call/cc
(lambda (next)
 (let-syntax ((CONTINUE (identifier-syntax (next))))
   (let () ;; allow definitions
     body ...)))) ; end call/cc
      incrmt
      (loop))) ; end let loop
  ))))) ;; close with-syntax
))))


mattei@acer:~$ guile
GNU Guile 3.0.9
Copyright (C) 1995-2023 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> (use-modules (Scheme+))
WARNING: (Scheme+): imported module (if-then-else) overrides core binding
`if'
WARNING: (Scheme+): imported module (when-unless) overrides core binding
`when'
WARNING: (Scheme+): imported module (when-unless) overrides core binding
`unless'

scheme@(guile-user)> (for ((define i 0) (< i 5) (set! i (+ i 1))) (define x
7) (display i)  (newline) (when (= i 2) (break "finish")))
0
1
2

here i should get "finish" at REPL but nothing happens?

regards


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2024-09-13 10:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-13  6:52 call/cc does not return a value Damien Mattei
2024-09-13  8:25 ` Mikael Djurfeldt
2024-09-13  9:15   ` Damien Mattei
2024-09-13  9:29     ` Mikael Djurfeldt
2024-09-13 10:52       ` Damien Mattei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).