[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How can I step through this code?
From: |
Ludovic Courtès |
Subject: |
Re: How can I step through this code? |
Date: |
Mon, 10 Oct 2022 18:04:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) |
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’.
- Re: How can I step through this code?, (continued)
- Re: How can I step through this code?, jbranso, 2022/10/07
- Re: How can I step through this code?, jgart, 2022/10/07
- Re: How can I step through this code?, jbranso, 2022/10/07
- Re: How can I step through this code?, jgart, 2022/10/07
- Re: How can I step through this code?, jbranso, 2022/10/08
- Re: How can I step through this code?, jgart, 2022/10/08
- Re: How can I step through this code?, jbranso, 2022/10/08
- Re: How can I step through this code?, jgart, 2022/10/09
- Re: How can I step through this code?, jbranso, 2022/10/10
- Re: How can I step through this code?, jgart, 2022/10/10
Re: How can I step through this code?,
Ludovic Courtès <=