No subject

From: ()
Date: Sat Mar 24 01:50:51 EDT 2012

no runtime evaluation of the program itself during compilation: the
compile-time phase is distinct from the run-time phase of a program.



One thing to note is that the macro system recognizes the use of
macros by name. But since the Racket language already provides a
"(define ...)" like form, we may want to hide it away if we're
defining our own language.  This is where the Racket "module" system
kicks in: modules allow us to carve out a language that provides just
our special forms.  That is, to "change" the existing definition of a
form is really to mask it away.

Let's say that we add to 'interleaving.rkt' the following:

    (provide (except-out (all-from-out racket)
                         define))
    (provide (rename-out (define/interleaved define)))

Then we can treat 'interleaving.rkt' as a language that acts just like
regular racket, except in the special case where we use define.  We
can write a new program in the same directory with the following
content:

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
#lang s-exp "interleaving.rkt"
(define (f x)
  (displayln "hello")
  (displayln "world"))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

And suddenly it looks as though "define" has been changed, and that's
because the use of define in this test program is really a use of
'define/interleaved': we've used the module system to reroute uses of
'define' to use our definition instead of the base one.

Posted on the users mailing list.