Hi everyone,<div><br><div>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.</div>
</div><div><br></div><div>I don't understand when macros are expanded. Low-level LISP style macros in particular.</div><div><br></div><div>1) I assume that all macros are expanded before compilation. </div><div>2) This raises the question about macros that are defined within the actual file to be compiled.</div>
<div>3) I guess that we scan through the file first to see what macros are defined?</div><div>4) But then what if the macros call a function that is also defined with the file?</div><div>5) Then we should scan through the file and see what functions are defined also.</div>
<div>6) What if the behaviour of the function is affected by a variable that's changed at runtime?</div><div><br></div><div>What should happen when I compile this?:</div><div><br></div><div><div>(define (reverse list)</div>
<div> (println "WILL I SEE THIS DURING COMPILE-TIME?")</div><div> (if (null? args)</div><div> '()</div><div> (append (reverse (cdr list)) (car list))))</div><div><br></div><div>(defmacro (reversely . args)</div>
<div> (reverse args))</div><div><br></div><div>(reversely ("WILL I SEE THIS DURING RUN-TIME?" println))</div></div><div><br></div><div><br></div><div>Thanks for your help</div><div> -Patrick</div>