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

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

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


Posted on the users mailing list.