thanks! this is all much clearer now :-)<br><br><div class="gmail_quote">On Sun, Jan 25, 2009 at 11:39 AM, Marc Feeley <span dir="ltr"><<a href="mailto:feeley@iro.umontreal.ca">feeley@iro.umontreal.ca</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="Ih2E3d"><br>
On 24-Jan-09, at 9:42 PM, symbolic expression wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
(define (foo x) (+ x 1))<br>
(define-macro (bar x) (foo x))<br>
(bar 10)<br>
<br>
this baffles me, if I open up gsi and paste this into the interpreter, I get 11<br>
however, if I stuff this in test.scm and run "gsi test.scm" I get:<br>
<br>
*** ERROR IN #<procedure #2>, "test.scm"@2.24 -- Unbound variable: foo<br>
<br>
what's going on? how do I fix this?<br>
</blockquote>
<br></div>
You are confusing the expansion time world and the run time world.  Check out the links Bill Six sent.<div class="Ih2E3d"><br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
<br>
[I would prefer that code in "gsi test.scm" has the same effect as if I type it into the interpreter]<br>
</blockquote>
<br></div>
If that is really what you want you can replace<br>
<br>
% gsi test.scm<br>
<br>
by<br>
<br>
% gsi -e '(for-each eval (read-all (open-input-file "test.scm")))'<br>
<br>
or do that in a source file.<br>
<br>
Finally, you can always define foo locally to bar:<br>
<br>
(define-macro (bar x)<div class="Ih2E3d"><br>
  (define (foo x) (+ x 1))<br></div>
  (foo x))<br>
<br>
(bar 10)<br>
<br>
or put foo's definition in a file (say foo.scm) and then:<br>
<br>
(define-macro (bar x)<br>
  (include "foo.scm")<br>
  (foo x))<br>
<br>
(bar 10)<br><font color="#888888">
<br>
Marc<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>-- symbolic expression<br>