[gambit-list] macro problems

lowly coder lowlycoder at huoyanjinjing.com
Thu Aug 13 06:32:37 EDT 2009


Why does the following work?

(define foo 2)
(pp (eval 'foo))

; --> 2

?

(sorry for my ignorane)

On Thu, Aug 13, 2009 at 3:27 AM, Adrien
Piérard<pierarda at iro.umontreal.ca> wrote:
> 2009/8/13 lowly coder <lowlycoder at huoyanjinjing.com>:
>> The following confuses me even more:
>
> You are mixing environments…
>
>> (define-macro (test)
>>  (define bar 3)
>
> Bar is defined in the body of the macro
>
>>  (pp (eval '(+ 1 2)))
>
> No bindings here, no problem
>
>>  (pp bar)
>
> This is bound to 3
>
>>  (pp (eval 'bar)))
>
> This bar is in another world.
> Try to add the second parameter to eval (the environment), just to be sure
>
>> (test)
>
> fail.
>
>
>
> In other words, look at that
> (define-macro (foo)
>  (define bar 3)
>  (eval '(define bar "hi"))
>  (pp bar)
>  (eval '(pp bar)))
>
> (foo)
>
>
> See the point?
>
> P!
>
> --
> Français, English, 日本語, 한국어
>



More information about the Gambit-list mailing list