[plt-scheme] (require mzscheme) issue

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Jan 9 08:37:31 EST 2008

At Tue, 08 Jan 2008 23:41:51 -0500, Psy-Kosh wrote:
> dumb question, but am using v372...
> isn't doing (require mzscheme), even at the top level, supposed to prevent  
> me from later redefining standard procs and so on?
> ie, shouldn't doing the following:
> (require mzscheme)
> (define + -)
> return an error?

No. You're free to re-bind names, though the binding doesn't effect
earlier uses in the top-level stream:

 > (require mzscheme)
 > (define (f x) (+ x 1))
 > (define + -)
 > (define (g x) (+ x 1))
 > (f 10)
 > (g 10)

My usual warning about the top level (it's hopeless) applies here. I
note that the warning is now part of section 1.3 of the new guide:

 Writing definitions outside of a module leads to bad error messages,
 bad performance, and awkward scripting to combine and run programs.
 The problems are not specific to `mzscheme'; they're fundamental
 limitations of the traditional top-level environment, which Scheme and
 Lisp implementations have historically fought with ad hoc command-line
 flags, compiler directives, and build tools. The module system is to
 designed to avoid the problems, so start with `#lang', and you'll be
 happier with PLT Scheme in the long run.


Posted on the users mailing list.