[racket] executable starting in submodule

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Apr 30 18:48:14 EDT 2014

Sorry for the long delay! I hope this answer is still useful.

Buried in the very long documentation for `create-embedding-executable`
is the note

 When submodules are available and included, the submodule is given a
 name by symbol-appending the write form of submodule path to the
 enclosing module's name.

For example, if "x.rkt" contains

 #lang racket/base
 'not-sub
 (module sub racket/base
   'sub)

then the name you want is '|x(sub)|:

 (create-embedding-executable
  "x"
  #:gracket? #f
  #:verbose? #f
  #:modules '((#f "x.rkt" (sub)))
  #:configure-via-first-module? #t
  #:literal-expression
  (parameterize ([current-namespace (make-base-namespace)])
    (compile `(namespace-require ''|x(sub)|))))


At Mon, 14 Apr 2014 17:06:15 +0200, Bert De Ketelaere wrote:
> Hello,
> 
> is it possible to let an embedded-executable start in a submodule?
> If yes, how do you do this?
> 
> I tried
>       (create-embedding-executable
>          exe-name
>          #:gracket? #f
>          #:verbose? #f
>          #:modules (if (build-subs B)
>                                  `((#f ,filename ,(submods))
>                                  `((#f ,filename)))
>          #:configure-via-first-module? #t
>          #:literal-expression
>          (parameterize ([current-namespace (make-base-empty-namespace)])
>            (namespace-require 'racket/base)
>            (if (build-subs B)
>                (compile `(namespace-require '(submod ',(string->symbol 
> (path->string short-program-name))
>                                                     
>                                     ,(string->symbol (build-subs B)))))
>                (compile `(namespace-require '',(string->symbol (path->string 
> short-program-name)))))))
> 
> but I get:
>     require: unknown module
>           module name: #<resolved-module-path:(submod 'filename submods)>
>           context...:
>            loop
> 
> Also, does the resolved-module-path structure mean that the path was completely 
> resolved during compilation, or only the first step?
> Any help would be appreciated,
> 
> Bert
>  		 	   		  ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users

Posted on the users mailing list.