[racket] Need a namespace

From: michael rice (nowgate at yahoo.com)
Date: Thu Jun 24 11:44:34 EDT 2010

Are my docs incorrect or out outdated?

Michael

===================

From: file:///usr/share/plt/doc/guide/eval.html#%28tech._current._namespace%29

#lang scheme
  
  (eval '(cons 1 2))

This fails because the initial current namespace is empty. When you run mzscheme in interactive mode (see Interactive Mode), the initial namespace is initialized with the exports of the scheme module, but when you run a module directly, the initial namespace starts empty.

In general, it’s a bad idea to use eval with whatever namespace happens to be installed. Instead, create a namespace explicitly and install it for the call to eval:

  #lang scheme
  
  (define ns (make-base-namespace))
  (eval '(cons 1 2) ns) ; works


--- On Thu, 6/24/10, Noel Welsh <noelwelsh at gmail.com> wrote:

From: Noel Welsh <noelwelsh at gmail.com>
Subject: Re: [racket] Need a namespace
To: "michael rice" <nowgate at yahoo.com>
Cc: users at racket-lang.org
Date: Thursday, June 24, 2010, 11:27 AM

You're using a define in a place where you aren't allowed to put a
define. E.g., this will work:

(define foo 1)

This won't work:

(define bar (define foo 1) foo)

N.



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100624/fc2871e5/attachment.html>

Posted on the users mailing list.