At Fri, 25 Aug 2017 16:04:01 +0200, Konrad Hinsen wrote:
> > Putting those together, and using `current-namespace` so that both
> > `eval-syntax` and check-module-form` use the same namespace:
> 
> Thanks, that works!
> 
> At least to the point of not getting any error message. I can't say if a 
> module is actually defined. 

I should have suggested setting `current-module-declare-name` during
evaluation of the module form, so that you get to pick the name:

  (parameterize ([current-namespace (make-base-namespace)])
    ;; Read module as a syntax object:
    (define mod-form
      (parameterize ([read-accept-lang #t]
                     [read-accept-reader #t])
        (read-syntax
         "test-module"
         (open-input-string
          "#lang scribble/base\n@section{Introduction}"))))

    ;; Declare the module:
    (parameterize ([current-module-declare-name 
                    ;; declare as name 'demo:
                    (make-resolved-module-path 'demo)])
      (eval mod-form))

    ;; Access the module with `dynamic-require`, `namespace-require`, etc.:
    (dynamic-require ''demo 'doc))

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to