[racket] require error

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Oct 18 13:09:42 EDT 2011

On Tue, Oct 18, 2011 at 12:00 PM, Marco Morazan <morazanm at gmail.com> wrote:
> On Tue, Oct 18, 2011 at 11:28 AM, Eli Barzilay <eli at barzilay.org> wrote:
>> `build-vector' is in the core `racket/base'.  To require just it in
>> the `eopl' language, you need to use the "raw" require forms, because
>> it's based on mzscheme:
>>  #lang eopl
>>  (require (only racket/base build-vector))
>>  (require "green.rkt")
>>  ...
> This (for now?) seems to have done the trick. Is there a rule I can
> actually explain to my students that they can rely on? In other words,
> I don't really see how/why requiring racket/base throws an error and
> the above does not.
> The above is ok if only a few functions are needed. It seems rather
> painful if many functions in racket/base are needed.

[ warning to the easily confused :), in the following paragraph I'm
going to use the words "scheme" "racket" and "mzscheme": in all cases,
I am referring to a particular set of languages in the technical sense
of our current "#lang" line lines, not in the more general sense of
"some programming language" or "some family of programming languages".
If you don't realize that, this message will be very confusing! ]

In the past we had a language called 'mzscheme' (separate from the
name of the ".exe" which we also used to have) that had certain things
working certain ways (require is slightly different than the require
you now know; lambda didn't have optional arguments, there was a
separate lambda; there are bunch of other differences all roughly on
this scale) and then we made a language called "scheme" which changed
those things as we attempted to clean up the language. (When we made
the name change from "PLT Scheme" to "Racket", the "scheme" language
that supplied (with very small changes) became the "racket" language;
the delta between mzscheme & scheme is much larger than the delta
between scheme and racket).

We still keep the old mzscheme language around because there are lots
of files that still use it and we slowly port them as we find the time
& need.

The eopl language was first built back in the time period when we had
the mzscheme language, but not yet the scheme language. In an effort
to avoid breaking people's eopl programs, we didn't change eopl to be
based on the newer scheme/base (or racket/base) language.

As to why requiring racket/base causes an error: I believe that what
is happneing is you are getting the racket/base version of require for
the second require (it is shadowing the mzscheme-based require that
#lang eopl introduces) and that version of require does not work well
inside a mzscheme language (for technical details having to do with
collaboration between the #%module-begin macro and require that I'm
not really sure about).

So all that said, I think you can tell your students to just avoid
racket/base and use other libraries that don't provide core things
like 'require'.

Meanwhile, we should really figure out a way to make eopl program
behave better when something like this happens. At a minimum there
should be an error message that makes sense somehow. (I don't have any
good ideas on how to achieve this, but someone that understands the
current error might.)


Posted on the users mailing list.