From: "Ludovic Courtès" <ludo@gnu.org>
To: jgart <jgart@dismail.de>
Cc: Guix Help <help-guix@gnu.org>
Subject: Re: How can I step through this code?
Date: Mon, 10 Oct 2022 18:04:57 +0200 [thread overview]
Message-ID: <87ilkrzmty.fsf@gnu.org> (raw)
In-Reply-To: <20221005220527.GB3151@dismail.de> (jgart@dismail.de's message of "Wed, 5 Oct 2022 22:05:27 -0500")
Hi,
jgart <jgart@dismail.de> skribis:
> How can I step through this code?
>
> (define-syntax do
> (syntax-rules ()
> ((do ((var init step ...) ...)
> (test expr ...)
> command ...)
> (letrec
> ((loop
> (lambda (var ...)
> (if test
> (begin
> (if #f #f)
> expr ...)
> (begin
> command
> ...
> (loop (do "step" var step ...)
> ...))))))
> (loop init ...)))
> ((do "step" x)
> x)
> ((do "step" x y)
> y)))
You can’t: this is a macro and Guile doesn’t have a “macro stepper”
(Racket does).
What you can do though, is define the macro and expand it on examples of
your choosing to see how it behaves:
--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> ,expand (do ((x 0 (+ 1 x))) ((>= x 10)) (pk x))
$7 = (let loop ((x 0))
(if (>= x 10)
(if #f #f)
(begin (pk x) (loop (+ 1 x)))))
scheme@(guile-user)> ,optimize (do ((x 0 (+ 1 x))) ((>= x 10)) (pk x))
$8 = (begin
(pk 0)
(pk 1)
(pk 2)
(pk 3)
(pk 4)
(pk 5)
(pk 6)
(pk 7)
(pk 8)
(pk 9)
(if #f #f))
--8<---------------cut here---------------end--------------->8---
(Personally I’ve never used ‘do’ and I don’t feel like starting today. :-))
Ludo’.
next prev parent reply other threads:[~2022-10-10 16:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-06 3:05 How can I step through this code? jgart
2022-10-07 18:45 ` jbranso
2022-10-07 19:22 ` jgart
2022-10-07 21:52 ` jbranso
2022-10-08 1:25 ` jgart
2022-10-08 15:03 ` jbranso
2022-10-08 17:23 ` jgart
2022-10-09 0:14 ` jbranso
2022-10-09 16:30 ` jgart
2022-10-10 19:49 ` jbranso
2022-10-10 22:40 ` jgart
2022-10-10 16:04 ` Ludovic Courtès [this message]
2022-10-10 17:00 ` jgart
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87ilkrzmty.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=help-guix@gnu.org \
--cc=jgart@dismail.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.