Hi Barry,

Thank you for the bug report, it was quite interesting.

On Sat 29 Aug 2009 17:49, Barry Fishman <barry_fish...@acm.org> writes:

> #! /bin/sh
> # -*- scheme -*-
> exec guile -s "$0" $*
> !#
>
> (load "dotimes.scm")
>
> (dotimes (indx 5)
>   (display indx)
>   (newline))

When compiling tryme, what happens is that `(load "dotimes.scm")' gets
compiled into a load at runtime -- but the dotimes.scm isn't loaded at
compile time.

Normally this wouldn't be a problem, but really what you want in this
case is for dotimes.scm to be loaded at compile time as well -- so that
the `dotimes' syntactic definition is present, so that the `dotimes'
invocation in `tryme' expands out to the right thing, instead of a call
to the dotimes function with three arguments.

So, your solutions are to either:

  (eval-when (eval load compile)
    (load "dotimes.scm"))

Or to put dotimes in a module. (Loading modules happens at compile time
as well.)


Now, does this indicate a bug in Guile, or at least an undesirable
behavior? That I do not know. You need to be careful with `load', that
if it provides syntactic definitions, you should probably load it at
compile time as well. This part of R5RS Scheme is somewhat
underspecified. Other schemes provide various load-for-syntax forms, or
loading modules for syntax forms.

For now what I would suggest is that you put your macro in a module.
Otherwise, do the eval-when dance. Or, if you have a better idea about
how this should work, I'd be interested in that, too.

Cheers,

Andy
-- 
http://wingolog.org/


Reply via email to