[Top][All Lists]

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

Re: macro definition for continue and break

From: Jean Abou Samra
Subject: Re: macro definition for continue and break
Date: Sun, 4 Sep 2022 12:08:39 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.0

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 ()
  (let loop ()
    (when test
  (call/cc (lambda (continue) b1 ...))

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)

;;; <stdin>:2:73: warning: possibly wrong number of arguments to `break'
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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]