unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jean Abou Samra <jean@abou-samra.fr>
To: Damien Mattei <damien.mattei@gmail.com>, guile-user <guile-user@gnu.org>
Subject: Re: macro definition for continue and break
Date: Sun, 4 Sep 2022 12:08:39 +0200	[thread overview]
Message-ID: <d8d8d260-fe1d-9202-98db-f4127f71d3d5@abou-samra.fr> (raw)
In-Reply-To: <CADEOadeqJ19SPQLUz9dqKNmQaedUYt5pSEiH=41NESPtaLr9-A@mail.gmail.com>



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.




  reply	other threads:[~2022-09-04 10:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-04  8:19 macro definition for continue and break Damien Mattei
2022-09-04 10:08 ` Jean Abou Samra [this message]
     [not found]   ` <CADEOadd2OAL-Z4o9AAR_mQ5_NSjCA1tVz5cDgeufVZ=ocAx0vQ@mail.gmail.com>
2022-09-04 11:13     ` Jean Abou Samra
2022-09-12 19:19       ` Linus Björnstam
2022-09-12 20:57         ` Loop macros (was: Re: macro definition for continue and break) Maxime Devos
2022-09-12 21:09           ` Linus Björnstam
2022-09-13 14:25           ` Damien Mattei
2022-09-13 14:28             ` Maxime Devos
2022-09-14 15:56               ` Damien Mattei
2022-09-13 14:16         ` macro definition for continue and break Damien Mattei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d8d8d260-fe1d-9202-98db-f4127f71d3d5@abou-samra.fr \
    --to=jean@abou-samra.fr \
    --cc=damien.mattei@gmail.com \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).