[gambit-list] Transforming top-level program code
feeley at iro.umontreal.ca
Wed Mar 13 07:08:59 EDT 2013
On 2013-03-12, at 11:52 PM, Jason Felice <jason.m.felice at gmail.com> wrote:
> I'm playing with macro-readtable-bracket-keyword-set! and can't get it to work when compiling files.
> I tried inline with the code, but realized that won't evaluate at compile time,
You are correct. This makes a change to the main readtable at run time (when the compiled program is executed).
> then did the define-macro/eval begin trick and found that brackets still don't expand.
That's because it makes a change to the main readtable at macro expansion time, which happens after the program has been parsed by read.
> It works fine in gsi.
You want to change the readtable before the source program is parsed. This can be done with the -e command line option which executes a Scheme expression before compiling the source files:
gsc -e '(include "~~lib/_gambit#.scm") (macro-readtable-bracket-keyword-set! ##main-readtable (quote ObjC-send))' test.scm
You could also create a "objc.scm" file with the code which modifies the reatable and do:
gsc -e '(load "objc.scm")' test.scm
You could also add the readtable modification to your gambcini.scm or gambcext.scm file. The GAMBCOPT environment variable is another way.
More information about the Gambit-list