Thanks for your prompt and clear reply.
I admit I don't fully understand the map? argument.
Just by trying out I know that for my purposes I always have to provide
true for the map? argument.
Meanwhile I insert the namespace-set-variable-value! line with true map?
argument, as you suggest.
Thanks again,
Jos

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of Jens Axel Søgaard
Sent: jueves, 27 de agosto de 2015 17:35
To: Jos Koot
Cc: Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


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  <file:///Applications/Racket%20v6.2/doc/reference/syntax-
model.html?q=namespace-va#%28tech._base._phase%29> base phase. The
namespace’s  <file:///Applications/Racket%20v6.2/doc/reference/syntax-
model.html?q=namespace-va#%28tech._identifier%29> identifier 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