[racket] export/import problem, and how to debug

From: Shriram Krishnamurthi (sk at cs.brown.edu)
Date: Tue Aug 3 14:25:38 EDT 2010

I see: each of these is a *separate* macro!  That clarifies it.  Thanks.

On Tue, Aug 3, 2010 at 2:22 PM, Jay McCarthy <jay.mccarthy at gmail.com> wrote:
> You didn't provide rename-in (etc).
>
> You need to provide all the require/provide transformers you want.
>
> Jay
>
> On Tue, Aug 3, 2010 at 12:13 PM, Shriram Krishnamurthi <sk at cs.brown.edu> wrote:
>> Let me see if I can reduce my problem to the simplest case.  Here is a
>> program that works fine:
>>
>> -----
>> #lang racket
>> (require (rename-in racket/tcp
>>                        (tcp-accept accept)
>>                        (tcp-listen listen)))
>> -----
>>
>> (It's from the docs, and it works as you would expect.  I only say all
>> this to say I've checked the syntax of this expression.)
>>
>> This is illegal in ASL:
>>
>> -----
>> #lang s-exp lang/htdp-advanced
>> (require (rename-in racket/tcp
>>                        (tcp-accept accept)
>>                        (tcp-listen listen)))
>> -----
>>
>>  require: expected a module name as a string, a `lib' form, or a
>>  `planet' form, found something else in: (rename-in racket/tcp
>>  (tcp-accept accept) (tcp-listen listen))
>>
>> [Same error if I use the (module ...) form at the REPL.]
>>
>> Let's say I want to give students access to require-on-steroids.  So I
>> define this language (sk-test-lang.rkt):
>>
>> -----
>> #lang racket
>> (require [except-in lang/htdp-advanced require])
>> (provide require
>>         [except-out (all-from-out lang/htdp-advanced)])
>> -----
>>
>> When I check syntax and highlight "require" on the provide line, the
>> arrow points to "racket".  Great.
>>
>> Now I try to use this.  First I'll do something simple (and you'll see
>> why in a moment):
>>
>> -----
>> #lang s-exp "sk-test-lang.rkt"
>> (require "lib.rkt")
>> -----
>>
>> This works fine, importing what lib.rkt provides.  When I check
>> syntax, the "require" comes from "sk-test-lang.rkt".  This hopefully
>> means that by transitivity, require comes from racket.
>>
>> So now I try this:
>>
>> -----
>> #lang s-exp "sk-test-lang.rkt"
>> (require (rename-in racket/tcp
>>                        (tcp-accept accept)
>>                        (tcp-listen listen)))
>> -----
>>
>> But I get
>>
>>  rename-in: not a require sub-form in: (rename-in racket/tcp
>>  (tcp-accept accept) (tcp-listen listen))
>>
>> The thing that boggles my mind is that this error message is NEITHER
>> the one that you would get from racket itself (since this is not an
>> error in racket), NOR the one from ASL (since I've shown you the error
>> text above).
>>
>> So:
>>
>> 1. Where is require coming from?
>>
>> 2. How could I go about figuring this for myself?  (The macro stepper
>> doesn't seem useful, or at least I don't see how to use it here.)
>>
>> 3. How do I fix my program? (-:
>>
>> Shriram
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://lists.racket-lang.org/listinfo/users
>>
>
>
>
> --
> Jay McCarthy <jay at cs.byu.edu>
> Assistant Professor / Brigham Young University
> http://teammccarthy.org/jay
>
> "The glory of God is Intelligence" - D&C 93
>


Posted on the users mailing list.