[racket] Confusion over compile-time / run-time

From: Patrick Li (patrickli.2001 at gmail.com)
Date: Sat Sep 4 18:15:22 EDT 2010

Hi everyone,

I'm writing a simple scheme compiler for educational purposes, and I'm
getting confused over "compile-time" versus. "run-time". If someone could
offer a simple explanation that would be greatly appreciated.

I don't understand when macros are expanded. Low-level LISP style macros in

1) I assume that all macros are expanded before compilation.
2) This raises the question about macros that are defined within the actual
file to be compiled.
3) I guess that we scan through the file first to see what macros are
4) But then what if the macros call a function that is also defined with the
5) Then we should scan through the file and see what functions are defined
6) What if the behaviour of the function is affected by a variable that's
changed at runtime?

What should happen when I compile this?:

(define (reverse list)
  (if (null? args)
      (append (reverse (cdr list)) (car list))))

(defmacro (reversely . args)
  (reverse args))

(reversely ("WILL I SEE THIS DURING RUN-TIME?" println))

Thanks for your help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100904/bf924f14/attachment.html>

Posted on the users mailing list.