[racket] Eval, namespaces redefinitions, and (maybe) code-inspectors

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Oct 15 00:03:16 EDT 2013

At Wed, 09 Oct 2013 22:34:08 -0400 (EDT), Galler wrote:
> But, is there a better way to prevent re-defining identifiers with 
> namespace-level binding?
> 
> Can I parameterize the namespace to prevent  re-definition of 
> namespace-level variables? Perhaps using code-inspectors?

I think that the only reflective operation currently for making
top-level definitions constant is `namespace-require/constant`:

 > (module m racket/base (define x 7) (provide x))
 > (namespace-require/constant ''m)
 > x
 7
 > (define x 8)
 define-values: assignment disallowed;
  cannot change constant
   constant: x

I don't see any obstacle to adding a more fine-grained reflective
operation, such as `namespace-set-variable-constant!`. Would that be
useful?


Posted on the users mailing list.