Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion submodule paths and DrRacket
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Asumu Takikawa  
View profile  
 More options Nov 18 2012, 9:36 pm
From: Asumu Takikawa <as...@ccs.neu.edu>
Date: Sun, 18 Nov 2012 21:31:49 -0500
Local: Sun, Nov 18 2012 9:31 pm
Subject: Re: [racket] submodule paths and DrRacket
On 2012-11-18 21:10:25 -0500, Harry Spier wrote:

>    Case 1 as follows works in the DrRacket Definitions window but doesn't
>    work in the Interactions window

>    #lang racket

>    (module m racket
>      (provide color)
>      (define color "blue"))
>    (module n racket
>      (require (submod ".." m))
>      (printf "my favorite color is ~a\n" color))

In the definitions window, the use of #lang implicitly wraps the entire
contents of the window in a module. This allows the use of relative
submodule references to module `m`.

In the interactions window, you are defining top-level modules instead.
You can get the same behavior if you wrap both `m` and `n` in another
module in the interactions window:

  (module around racket
    ;; put m and n here
    ...)

>    Case 2 as follows works in the DrRacket Interactions window but doesn't
>    work in the Definitions window

>    > (module m racket
>        (provide color)
>        (define color "blue"))
>      (module n racket
>        (require 'm)
>        (printf "my favorite color is ~a\n" color))
>      (require 'n)

This time, it works in the interactions window because they are both
top-level modules. Within a module, you can't refer to the parent's
submodules directly with a quoted name.

>    Also is there a way to have

>     #lang racket

>     (module m racket
>       (provide color)
>       (define color "blue"))

>    in the definitions window but the following in the interactions window

>    >(module n racket
>       (require SOME SUBMODULE PATH TO m)
>       (printf "my favorite color is ~a\n" color))
>     (require 'n)

Yes. Suppose the first snippet is defined in "foo.rkt". Then you can
just have (require (submod "foo.rkt" m)) if you're in the right
directory.

Cheers,
Asumu
____________________
  Racket Users list:
  http://lists.racket-lang.org/users


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.