From: Damien Mattei <damien.mattei@gmail.com>
To: Zelphir Kaltstahl <zelphirkaltstahl@posteo.de>
Cc: guile-user <guile-user@gnu.org>, guile-devel <guile-devel@gnu.org>
Subject: Re: case source code
Date: Mon, 12 Sep 2022 10:27:23 +0200 [thread overview]
Message-ID: <CADEOadcatFdX8xJ0-9BFVxxw2+uquRt2VTTYPKLMfOmn8OYbMw@mail.gmail.com> (raw)
In-Reply-To: <f4df07bb-ee4c-1306-bf63-8b4caf83f3f8@posteo.de>
sorry if my question was unclear , i search the source code if it exist in
scheme with macro (or not) but not in C for the 'case function (procedure
or macro) , i want to modify the code to allow inner definitions the way i
do it for example with 'do:
;; with a definition inside only the new version works:
;; (do ((i 1 (1+ i))
;; (p 3 (* 3 p)))
;; ((> i 4)
;; p)
;; (define x 7)
;; (set! p (+ p i x)))
;; $3 = 1257
(define-syntax do
(syntax-rules ()
((do ((var init step ...) ...)
(test expr ...)
command ...)
(letrec
((loop
(lambda (var ...)
(if test
;;(begin
(let ()
#f ; avoid empty begin
expr ...)
;;(begin
(let ()
command
...
(loop (do "step" var step ...)
...))))))
(loop init ...)))
((do "step" x)
x)
((do "step" x y)
y)))
regards,
Damien
On Mon, Sep 12, 2022 at 9:46 AM Zelphir Kaltstahl <
zelphirkaltstahl@posteo.de> wrote:
> Hello Damien,
>
> On 9/12/22 09:42, Damien Mattei wrote:
> > Hello,
> > i can not find in the scheme community a definition of 'case in term of
> > macro as for when, unless,while,do... does anyone have it?
> > thanks,
> > Damien
>
> Can you give an example of what form you mean?
>
> Regards,
> Zelphir
>
> --
> repositories: https://notabug.org/ZelphirKaltstahl
>
>
next prev parent reply other threads:[~2022-09-12 8:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-12 7:42 case source code Damien Mattei
2022-09-12 7:46 ` Zelphir Kaltstahl
2022-09-12 8:27 ` Damien Mattei [this message]
2022-09-12 8:30 ` Damien Mattei
2022-09-12 8:47 ` Taylan Kammer
2022-09-13 9:18 ` 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=CADEOadcatFdX8xJ0-9BFVxxw2+uquRt2VTTYPKLMfOmn8OYbMw@mail.gmail.com \
--to=damien.mattei@gmail.com \
--cc=guile-devel@gnu.org \
--cc=guile-user@gnu.org \
--cc=zelphirkaltstahl@posteo.de \
/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).