* Macro expansion
@ 2011-01-11 13:34 Hans Aberg
2011-01-15 20:39 ` Neil Jerram
0 siblings, 1 reply; 4+ messages in thread
From: Hans Aberg @ 2011-01-11 13:34 UTC (permalink / raw)
To: guile-user
In the code below the 'loop' and 'begin' examples will execute the
'while' loop, but if put into the body of a function, 'while' will not
run. So why, and how to fix it?
Just copy and paste the examples below into guile. For the two first,
I get
0123456789
0123456789done!3
but for the third, the thunk, only
done!3
So the macro 'while' is not expanded as expected.
Hans
(use-syntax (ice-9 syncase))
(define-syntax loop
(syntax-rules ()
((loop (j ...) p (r ...) (x ...))
(begin j ... (while p x ... r ...)))
))
(loop ((define i 0))
(< i 10)
((set! i (+ i 1)))
((display i)))
(begin
(loop ((define i 0))
(< i 10)
((set! i (+ i 1)))
((display i)))
(display "done!")
(+ 1 2)
)
((lambda
()
(begin
(loop ((define i 0))
(< i 10)
((set! i (+ i 1)))
((display i)))
(display "done!")
(+ 1 2)
)
))
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Macro expansion
2011-01-11 13:34 Macro expansion Hans Aberg
@ 2011-01-15 20:39 ` Neil Jerram
2011-01-15 23:11 ` Hans Aberg
2011-01-16 14:43 ` Hans Aberg
0 siblings, 2 replies; 4+ messages in thread
From: Neil Jerram @ 2011-01-15 20:39 UTC (permalink / raw)
To: Hans Aberg; +Cc: guile-user
Hans Aberg <haberg-1@telia.com> writes:
> In the code below the 'loop' and 'begin' examples will execute the
> while' loop, but if put into the body of a function, 'while' will not
> run. So why, and how to fix it?
>
> Just copy and paste the examples below into guile. For the two first,
> I get
> 0123456789
> 0123456789done!3
> but for the third, the thunk, only
> done!3
With my current Guile,
scheme@(guile-user)> (version)
$4 = "1.9.14.17-44f43"
the third case behaves as you would expect:
scheme@(guile-user)> ((lambda
()
(begin
(loop ((define i 0))
(< i 10)
((set! i (+ i 1)))
((display i)))
(display "done!")
(+ 1 2)
)
))
0123456789done!$5 = 3
Regards,
Neil
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Macro expansion
2011-01-15 20:39 ` Neil Jerram
@ 2011-01-15 23:11 ` Hans Aberg
2011-01-16 14:43 ` Hans Aberg
1 sibling, 0 replies; 4+ messages in thread
From: Hans Aberg @ 2011-01-15 23:11 UTC (permalink / raw)
To: Neil Jerram; +Cc: bug-guile, guile-user
On 15 Jan 2011, at 21:39, Neil Jerram wrote:
> With my current Guile,
>
> scheme@(guile-user)> (version)
> $4 = "1.9.14.17-44f43"
>
> the third case behaves as you would expect:
That is right, I used the stable versions 1.8.x, x = 7, 8.
Unfortunately, when I try to install guile-1.9.14, I get the error
below (Mac OS X 10.5.8 PPC G4).
ld: duplicate symbol ___gmpz_abs in .libs/libguile_2.0_la-arbiters.o
and .libs/libguile_2.0_la-alist.o
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Macro expansion
2011-01-15 20:39 ` Neil Jerram
2011-01-15 23:11 ` Hans Aberg
@ 2011-01-16 14:43 ` Hans Aberg
1 sibling, 0 replies; 4+ messages in thread
From: Hans Aberg @ 2011-01-16 14:43 UTC (permalink / raw)
To: Neil Jerram; +Cc: guile-user
On 15 Jan 2011, at 21:39, Neil Jerram wrote:
> With my current Guile,
>
> scheme@(guile-user)> (version)
> $4 = "1.9.14.17-44f43"
>
> the third case behaves as you would expect:
When I upgrade, then it too works. So it was a bug that has been
fixed, then.
scheme@(guile-user)> (version)
$1 = "1.9.14.68-a7d8a"
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-01-16 14:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-11 13:34 Macro expansion Hans Aberg
2011-01-15 20:39 ` Neil Jerram
2011-01-15 23:11 ` Hans Aberg
2011-01-16 14:43 ` Hans Aberg
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).