On Wednesday, September 25, 2019 at 1:37:41 PM UTC+8, Jesse Alama wrote:
>
> I'm working on building a standalone executable for a #lang that can be 
> used in two ways:
>
> 1. foo awesome.foo: execute file awesome.foo, which is written in #lang foo
>
> 2. foo (no arguments): fire up a REPL. Expressions are to be written in 
> the foo language.
>
> I can get (1) to work, after wrestling with raco exe (using ++lang) and 
> raco distribute (using ++collects-copy). An invocation that works for me is:
>
> ### begin script snippet
>
> raco exe ++lang foo ++lang racket/base ++lang brag foo.rkt
>
> # copy the source code of foo into collects/foo
> mkdir -p collects/foo
>
> find . -mindepth 1 -maxdepth 1 -name '*.rkt' -exec cp {} collects/foo ';'
>
> raco distribute ++collects-copy collects dist foo
>
> ### end script snippet
>
> This works for making a standalone executable that can exectute foo 
> programs specified on the command line, but doesn't work for a REPL. The 
> difficulty seems to be the `namespace-require` part of `run-repl`, defined 
> like this:
>
> ````
> (define (run-repl)
>   (parameterize ([current-namespace (make-base-empty-namespace)])
>     (namespace-require 'foo/expander)
>     (read-eval-print-loop)))
> ````
>

This is a wild guess, but since no one replied, I would suggest two things 
to try:

1) try using `make-base-namespace` instead -- I am not sure what the 
difference is between "attached" and "attached + required", but sounds like 
`make-base-namespace` will require racket/base

2) try a compiled form:

    (define (run-repl)
      (parameterize ([current-namespace (make-base-empty-namespace)])
        (compile `(namespace-require `'foo/expander))
        (read-eval-print-loop)))

Alex. 


> When I invoke the executable with no arguments, `run-repl` gets called. 
> But this leads to:
>
> ````
> standard-module-name-resolver: collection not found
>   for module path: racket/base/lang/reader
>   collection: "racket/base/lang"
> ````
>
> expander.rkt in foo is written in racket/base, so I suppose that's what 
> triggers the issue.
>
> My question, crudely put, is: How do I "embed" racket/base so that I can 
> use `namespace-require` as seen in `run-repl`? (I assume namespace-require 
> is what I need; if that's wrong, please do correct me.) It appears that 
> ++lang racket/base bit in raco exe isn't enough. A related question about 
> raco exe is: if racket/base isn't available, what *is* available?
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/0590b28c-2d3a-4245-a4da-c6deee8c53c3%40googlegroups.com.

Reply via email to