[racket] dynamic-require and submod

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Wed May 29 09:16:57 EDT 2013

The module names "." and ".." are relative.  There's no way for
dynamic-require to use them unambiguously -- they have to be resolved at
compile time.  In this case, you need to either use a module path for the
enclosing module yourself, or move the resolution to compile-time using
quote-module-path:

#lang racket

(module m racket
  (define x 123)
  (provide x))

(require syntax/location)
(define path-to-m
  (quote-module-path m))

Then at the REPL:

> (dynamic-require path-to-m 'x)
123

Carl Eastlund


On Wed, May 29, 2013 at 5:19 AM, Tobias Hammer <tobias.hammer at dlr.de> wrote:

> Hi,
>
> any idea why this is not working?
>
> #lang racket
>
> (module m racket
>   (define x 123)
>   (provide x))
>
> (dynamic-require '(submod "." m) 'x)
> ;> standard-module-name-resolver: no base path for relative submodule
> path: (submod "." m)
>
> ; OR
>
> (dynamic-require ''m 'x)
> ;> dynamic-require: unknown module
> ;  module name: #<resolved-module-path:'m>
>
>
> The equivalent require statements work as expected.
> Strangely exactly these cases are checked in test/racket/submodule.rktl
> (I suppose tests are kind of eval'd as my example runs with #lang
> racket/load)
>
> Tobias
>
>
> --
> ------------------------------**---------------------------
> Tobias Hammer
> DLR / Robotics and Mechatronics Center (RMC)
> Muenchner Str. 20, D-82234 Wessling
> Tel.: 08153/28-1487
> Mail: tobias.hammer at dlr.de
> ____________________
>  Racket Users list:
>  http://lists.racket-lang.org/**users <http://lists.racket-lang.org/users>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130529/ab80c1c2/attachment-0001.html>

Posted on the users mailing list.