[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Repeat syntax
From: |
Alex Vong |
Subject: |
Re: Repeat syntax |
Date: |
Sat, 25 Nov 2017 16:39:13 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
Christopher Howard <address@hidden> writes:
> Hi list, I want to have a function
>
> (repeat n exp exp* ...)
>
> That calls the expressions n times for side effect, like for-each, but
> without the bother of dealing with a list. It seems like somebody else
> must have thought of this before, but I couldn't find the equivalent
> procedure. After reading 6.10.2 I came up with this
>
> (define-syntax repeat
> (syntax-rules (repeat)
> ((_ n exp exp* ...)
> '(unless (<= n 0)
> exp
> exp*
> ...
> (repeat (- n 1) exp exp* ...)))))
>
> Which doesn't work I think because repeat gets expanded infinitely many
> times. I was pondering other ways to do this, but they all seem to end
> in either infinite expansion, or an important variable getting
> overshadowed. So, could somebody point me in the right direction?
Do you want to evaluate the expressions during macro-expand-time or
run-time?
signature.asc
Description: PGP signature