[plt-dev] make eval namespace argument mandatory

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Mar 17 18:22:57 EDT 2010

On Mar 17, Ryan Culpepper wrote:
> For racket, I propose we make the namespace argument to the 'eval'
> function mandatory. It's currently optional, and one-arg 'eval' is
> an attractive nuisance. If programmers have to specify the
> evaluation context---especially if they have to read up on
> namespaces to figure out how to get one---they are less likely to
> expect magical behavior from one-arg 'eval'.

It seems like a drastic fix that can mostly be dealt with in other
ways like making `eval' do something like:

  (define (better-eval expr [ns (current-namespace)])
    (if (namespace-empty? ns)
      (error 'eval "proper explanation of what you did wrong")
      (eval expr ns)))

Another option is to throw it out completely, and instead replace it
with a `make-evaluator' function that creates an evaluator in the
context of a given namespace -- and that will be nice in the sense
that you can choose the `current-namespace', the module's namespace,
a sandboxed namespace, etc.


On Mar 17, Sam Tobin-Hochstadt wrote:
> 
> I would also suggest than anything the operates on the
> current-namespace *without* at least an optional namespace argument
> be fixed.  A few examples are: `namespace-require',
> `namespace-require/copy', `namespace-symbol->identifier',
> `namespace-syntax-introduce'.

If that's done then there's a much weaker point in a
`current-namespace' parameter.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.