The issue here is whether the namespance's identifier mapping is used or
not.

The documentation for namespace-undefine-variable! says:

    Removes the sym variable, if any, in the top-level environment of
namespace in
    its base phase
<file:///Applications/Racket%20v6.2/doc/reference/syntax-model.html?q=namespace-va#%28tech._base._phase%29>.
The namespace’s identifier
<file:///Applications/Racket%20v6.2/doc/reference/syntax-model.html?q=namespace-va#%28tech._identifier%29>
mapping
(see Namespaces
<file:///Applications/Racket%20v6.2/doc/reference/syntax-model.html?q=namespace-va#%28part._namespace-model%29>)
is
     unaffected.

We can see that  list  is use the identifier mapping by changing the second
argument of namespace-variable-value to #f.

    #lang racket
    (define ns (make-base-namespace))
    (namespace-variable-value 'list #f (λ () 'not-found) ns)

which evaluates to 'not-found.

Inserting your own non-imported value for  list  makes the identifier
non-imported and has
the happy side-effect of making namespace-undefined-variable! capable of
removing the
binding from namespace.

In some sense  namespace-undefined-variable!  miss an map? argument.
Your solution: insert, then undefine  seem to be the best solution for now.

/Jens Axel

you n


2015-08-27 16:53 GMT+02:00 Jos Koot <[email protected]>:

> The following works:
>
> #lang racket/base
> #;1 (define ns (make-base-namespace))
> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
> ; -> #<procedure:print-syntax-width>
> #;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
> #;4 (namespace-undefine-variable! 'list ns)
> #;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
> ; -> not-found
>
> But when I omit line 3 it does not work:
>
> #lang racket/base
> #;1 (define ns (make-base-namespace))
> #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; ->
> #<procedure:list>
> #;4 (namespace-undefine-variable! 'list ns)
> ;-> error namespace-undefine-variable!: given name is not defined
> ;       name: list
>
> This I did with: Welcome to DrRacket, version
> 6.2.0.5--2015-07-06(d6fa581/a) [3m].
> Code in the definitions window. The problem is not typical for 'list only.
> The same happens with (at least some) other variables of a base-namespace.
>
> I have no clue why commenting out line 3 gives an error.
> Do I misinterpret the docs on namespaces?
>
> Thanks, Jos
>
> PS I use a base-namespace in a toy interpreter.
> It allows me to easily borrow all variables from a base-namespace.
> But some of them I want to undefine.
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
-- 
Jens Axel Søgaard

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to