[plt-scheme] Am I being required or...?
Eli Barzilay wrote:
> * Have some macro that looks like this:
>
> (define mains (make-hash))
> (define-syntax-rule (main-begin body ...)
> (hash-set! mains the-source-file (lambda () ...)))
>
> where `the-source-file' is actually getting the source path of the
> macro use (so it actually can't be done with `define-syntax-rule'),
> then write a `run' script that expects a file, requires it, and runs
> the appropriate thunk -- something like:
>
> (require a b c d)
> (define (main file)
> ((hash-ref mains file)))
>
> and use this file like this:
>
> mzscheme run b
>
> (So this is similar to the previous trick only done in scheme.)
I like this idea, but that would mean the run script would have to
require every module that could possibly have one such entry point to
it. It'd be better if you could use dynamic-require, just for the root
source that in turn requires the module you need.
I made a variant of the above idea, and it works... but it stops working
when it's compiled to an executable. For some reason the global
mutations done within a dynamic-require'd module don't have any effect
when run.ss is run with mzc --exe. Also it loses the system
collects-path? :(
I'm probably just using mzc --exe wrong. Assistance would be welcome.
I'll attach the files I used, nothing really complicated.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: main.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20100329/11b4a761/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: run.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20100329/11b4a761/attachment-0001.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.ss
URL: <http://lists.racket-lang.org/users/archive/attachments/20100329/11b4a761/attachment-0002.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.sh
Type: application/x-sh
Size: 328 bytes
Desc: not available
URL: <http://lists.racket-lang.org/users/archive/attachments/20100329/11b4a761/attachment.sh>