[racket] provide and require in submodules
No, the error in this case is as intended.
While a module is being compiled, the module does not yet claim to be
the module that it will be when it is run. That is, while "things.rkt"
is compiled, it is just "the module currently being compiled", and not
the "things.rkt" module. So, `(submod "..")' works because it is in
terms of the module being compled, while "things.rkt" isn't.
At Fri, 23 Nov 2012 21:40:01 -0500, Harry Spier wrote:
> Thanks Matthew,
>
> Is this also the same/similar bug but with submodule path as filename?
>
> This works:
> -----------------------------------------------------------------
> #lang racket ;; client.rkt
> (require (submod "things.rkt" extra-things))
> (displayln thing-a)
>
> #lang racket ;; things.rkt
> (provide thing-a thing-b)
>
> (define thing-a 'thing-a)
> (define thing-b 'thing-b)
>
> (module+ extra-things
> (provide (all-from-out (submod "..")))
> (provide all-defined-out)
>
> (define extra-thing-c 'extra-thing-c)
> (define extra-thing-d 'extra-thing-d))
>
> RUNNING client.rkt GIVES:
>
> > thing-a
> ------------------------------
> BUT
>
> #lang racket ;; client.rkt
> (require (submod "things.rkt" extra-things))
> (displayln thing-a)
>
> #lang racket ;; things.rkt
> (provide thing-a thing-b)
>
> (define thing-a 'thing-a)
> (define thing-b 'thing-b)
>
> (module+ extra-things
> (provide (all-from-out "things.rkt")) ;;CHANGED (submod "..")
> ;;TO "things.rkt"
> (provide all-defined-out)
>
> (define extra-thing-c 'extra-thing-c)
> (define extra-thing-d 'extra-thing-d))
> ------------------------
> RUNNING client.rkt GIVES ERROR
> things.rkt:8:25: all-from-out: no corresponding require in: "things.rkt"
>
> Thanks,
> Harry Spier
>
> On Fri, Nov 23, 2012 at 10:31 AM, Matthew Flatt <mflatt at cs.utah.edu> wrote:
>
> > That's a bug. I've pushed a repair to the git repo.
> >
> > Thanks for the report!
> >
> > At Tue, 20 Nov 2012 23:19:30 -0500, Harry Spier wrote:
> > > Dear list members,
> > >
> > > This works in DrRacket:
> > > definitions window
> > > -------------------------
> > > #lang racket
> > > (module+ server
> > > (provide a-from-server)
> > > (define a-from-server 'a-from-server))
> > >
> > > (module+ client
> > > (module server2 racket
> > > (provide b-from-server2)
> > > (define b-from-server2 'b-from-server2))
> > >
> > > (require (submod ".." server))
> > > (provide (all-from-out (submod ".." server)))
> > >
> > > (require 'server2)
> > > (provide (all-from-out (submod "." server2))))
> > >
> > > (module+ main
> > > (require (submod ".." client))
> > > a-from-server
> > > b-from-server2)
> > >
> > > Results in interactions window
> > > ---------------
> > > >
> > > 'a-from-server
> > > 'b-from-server2
> > >
> > > BUT the following gives me the error: "all-from-out: no corresponding
> > > require in: (quote server2)"
> > > Could someone explain why I'm getting this error.
> > >
> > > Definitions window
> > > ------------------
> > > #lang racket
> > > (module+ server
> > > (provide a-from-server)
> > > (define a-from-server 'a-from-server))
> > >
> > > (module+ client
> > > (module server2 racket
> > > (provide b-from-server2)
> > > (define b-from-server2 'b-from-server2))
> > >
> > > (require (submod ".." server))
> > > (provide (all-from-out (submod ".." server)))
> > >
> > > (require 'server2)
> > > (provide (all-from-out 'server2))) ;;;CHANGED (submod "." server2) TO
> > > 'server2
> > >
> > > (module+ main
> > > (require (submod ".." client))
> > > a-from-server
> > > b-from-server2)
> > >
> > > Thanks,
> > > Harry Spier
> > > ____________________
> > > Racket Users list:
> > > http://lists.racket-lang.org/users
> >
> >
> ____________________
> Racket Users list:
> http://lists.racket-lang.org/users