Yes, attaching a module instances doesn't `require` it anywhere.

(Sorry --- I didn't look at your program closely enough to work out
whether you meant to require it, start out with a non-empty namespace,
or something else.)

At Fri, 16 Apr 2021 18:02:47 +0000, Sage Gerard wrote:
> Yes. The error changed to "hello: unbound identifier, also no #%app ..."
> for me, so I also had to add `(namespace-require (quote-module-path
> restricted) ns)` to get it working.
> 
> Were you expecting that I had to do that too? The docs for the
> `make-base-*-namespace` procedures make it sound like attaching is
> sufficient.
> 
> 
> On 4/16/21 1:51 PM, Matthew Flatt wrote:
> > The name `'restricted` is allowed as a shorthand in `require` because
> > `require` knows what module it's in. The `namespace-attach-module`
> > function does not try to infer a module context from the namespace
> > argument; it uses the namespace argument only for its registry. So, you
> > need to use the full name of the submodule.
> >
> > The `quote-module-path` form expands to a full name using its syntactic
> > context (i.e., the enclsoing module's name), so
> >
> >    (namespace-attach-module (namespace-anchor->namespace a)
> >                             (quote-module-path restricted)
> >                             ns)
> >
> > is probably what you want.
> >
> >
> > At Fri, 16 Apr 2021 17:29:28 +0000, Sage Gerard wrote:
> >> Why does this raise "namespace-attach-module: module not declared (in
> >> the source namespace)"?
> >>
> >> I expected that the `restricted` submodule would be both declared and
> >> instantiated by the time control reached `namespace-attach-module`.
> >>
> >> (module anon racket/base
> >>     (module restricted racket/base
> >>       (provide #%app #%datum #%top hello)
> >>       (define (hello h) h))
> >>     (require 'restricted)
> >>     (define ns (make-empty-namespace))
> >>     (define-namespace-anchor a)
> >>     (namespace-attach-module (namespace-anchor->namespace a) ''restricted 
> >> ns)
> >>     (displayln (eval '(hello "world") ns)))
> >>
> >> --
> >> ~slg
> 
> --
> ~slg
> 
> 
> -- 
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/racket-users/e11dff02-0a27-06bd-9b4c-128f15e65
> 849%40sagegerard.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20210416121152.2b0%40sirmail.smtps.cs.utah.edu.

Reply via email to