I think you’ll need `define-runtime-module-path` or
`define-runtime-module-path-index` to alert the executable builder to the
dynamic dependency.

On Sun, Nov 15, 2020 at 3:38 AM Dominik Pantůček <
dominik.pantu...@trustica.cz> wrote:

>
> >
> > Using ''sandbox as an argument to `namespace-require` to refer to a
> > local module is something like passing 'x to `eval` to try to refer to
> > a local variable `x`. The `namespace-require` procedure doesn't know
> > where it's being called from, so it doesn't work.
> >
> > Try `quote-module-path`, which expands at compile time to effectively
> > embed its context:
> >
> >  #lang racket/base
> >  (require syntax/location)
> >
> >  (module sandbox racket/base
> >    (provide #%app #%datum test)
> >    (define (test) (displayln 'test)))
> >
> >  (parameterize ((current-namespace (make-base-empty-namespace)))
> >    (namespace-require (quote-module-path sandbox))
> >    (eval '(test)))
> >
>
> This is exactly what I was looking for! Thank you. It's a pity I didn't
> ask in the past :)
>
> However, now I see a problem with creating executables with raco exe.
>
> MWE follows.
>
> ==== test-submod.rkt
> #lang racket
>
> (require syntax/location)
>
> (module my-dsl racket/base
>
>   (provide #%app my-proc)
>
>   (define (my-proc)
>     (displayln "my-dsl/my-proc")))
>
> (define (parse sexp)
>   (parameterize ((current-namespace (make-base-empty-namespace)))
>     (namespace-require (quote-module-path my-dsl))
>     (eval sexp)))
>
>
> (parse '(my-proc))
> ====
>
> And then:
>
> $ ../racket-lang/racket/racket/bin/racket --version
> Welcome to Racket v7.9.0.4 [cs].
> $ ../racket-lang/racket/racket/bin/racket test-submod.rkt
> my-dsl/my-proc
> $ ../racket-lang/racket/racket/bin/raco exe test-submod.rkt
> $ ./test-submod
> require: unknown module
>   module name: (submod '#%mzc:test-submod my-dsl)
>   context...:
>    .../TD4/test-submod.rkt:12:0: parse
>    body of '#%mzc:test-submod
> $
>
> When parsed, compiled and run using racket binary, it works as expected.
> When parsed and compiled using raco exe, it succeeds without any error
> and the resulting binary give aforementioned error.
>
> Any idea where did I get it wrong?
>
>
> Dominik
>
> --
> 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/d357eb72-0647-d542-5148-852b9e62c2a2%40trustica.cz
> .
>
-- 
-Philip

-- 
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/01000175cd1985dd-8b6d9cec-b745-4479-a3db-b092fd340434-000000%40email.amazonses.com.

Reply via email to