Le 04/09/2022 à 10:19, Damien Mattei a écrit :
my previous question ,clearly more, is :
(define-syntax for/bc
(syntax-rules (continue break)
((_ (init test incrmt) b1 ...)
(call/cc (lambda (break)
(let ()
init
(let loop ()
(when test
(call/cc (lambda (continue) b1 ...))
incrmt
(loop)))))))))
is there a way to make working this macro in a R6RS compatible way (i know
it is possible in Racket or with syntax features...)
to avoid error:
(for/bc ({i <+ 0} {i < 5} {i <- {i + 1}})
{x <+ 7}
(display x)
(newline)
(break))
;;; <stdin>:2:73: warning: possibly wrong number of arguments to `break'
7
ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Wrong number of arguments to #<procedure break (pred clist)>
Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
You seem to be mistaken about what the literals list in syntax-rules
does. It
enables literal matching in the pattern part, and only has an effect on the
patterns. It does not make 'break' in the expanded body expand as an
unhygienic
identifier. It allows to recognize keywords, but not to introduce them. Yo
need to use datum->syntax for that. You're getting a break procedure from
somewhere else:
scheme@(guile-user)> (use-modules (srfi srfi-1))
scheme@(guile-user)> break
$1 = #<procedure break (pred clist)>
You seem to have corrected this mistake in your second post with
a similar question, so I'll continue on that thread.