[gambit-list] macro vs runtime environment

Adrien Piérard pierarda at iro.umontreal.ca
Sat Aug 15 03:43:28 EDT 2009


> Isn't one of the core tenents of define-macro that it's just lisp code
> generating lisp code?

For what kind of lisp code?
Gambit-specific code? Larceny-specific code? Just R4RS-specific code?
Is it portable?

What define-macro allows is implementation specific, but the bare
minimum might not even be full R4RS compliant…

> You most definitely did. I don't think I quite understand it yet.

Read it again ^^


>> And also, you *want* a different environment than the runtime one…
> Why? If I want to avoid naming clash, I can just put them in different
> namespaces.

Err, namespaces are *not* even in R5RS. How would you then expect
macro to work in previous versions of Scheme ?

Moreover, with a common namespace, what would happen to such code?

(define-macro (foo)
  (define + (lambda (x y) 42))
  (pp "foo"))

(foo)
(pp (+ 1 2)) ;; 42 !!!!!!!!!!!!!!

You would not like that would you?

Consider that,
"A macro is an external program with takes a scheme source and returns
a scheme source",
then "A macro is an external program",
then you do not want the variables defined in an external program to
mask thoses of the processed data, do you?
It's not even a matter of namespace. It's two different worlds.
The names defined in your OS do not influence the results of the
programs you write. Yet, your OS is handling your source code as a
(dummy) macro would do.

Please read Queinnec's book. Or write your own macro expanser.

P!

-- 
Français, English, 日本語, 한국어



More information about the Gambit-list mailing list