RE: [racket-users] namespace-undefine-variable! question

2015-08-28 Thread Jos Koot
Hi Jens Axel
That's a very clear answer. Thanks.
I don't know why procedures acting on namespaces treat directly imported
identifiers differently than imported identifiers.May be there is a reason,
but don't bother, Of cource it is always nice to know how things work, but
in the present case I am happy to know how to handle the map? argument,
even without knowing the reason the inclusion of a map? argument in a
number of functions actnig on namespaces. I am sure it can be useful in
some cases, but I never have encountered those cases. 
 
Of course +1 to the idea of adding a map? argument to namespace-undefine-
variable!.
 
Thanks again, Jos

  _  

From: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] On
Behalf Of Jens Axel Søgaard
Sent: viernes, 28 de agosto de 2015 13:48
To: Jos Koot
Cc: Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


As far as I can tell a namespace knows if an identifier is defined directly
in the module or if it is imported. 
If map? is #t then, imported identifiers are handled - and if map? is #f
then only identifiers defined directly in the module is handled. Since
namespace-undefined-variable! has no map? argument, you can't undefine
imported variables.

Why the map? argument is missing from namespace-undefined-variable! I don't
know

/Jens Axel


2015-08-27 19:24 GMT+02:00 Jos Koot jos.k...@gmail.com:



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: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] 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 base phase. The namespace’s identifier mapping (see Namespaces) 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 jos.k...@gmail.com:



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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.





-- 

-- 
Jens Axel Søgaard






-- 

-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Jens Axel Søgaard
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 jos.k...@gmail.com:

 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 racket-users+unsubscr...@googlegroups.com.
 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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
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: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] 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 jos.k...@gmail.com:



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 racket-users+unsubscr...@googlegroups.com.
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Deren Dohoda
Hi Jos,
But some of them I want to undefine.
Isn't it easier to make your own restricted #lang and then use
make-module-evaluator? Sorry to butt in.

Deren

On Thu, Aug 27, 2015 at 1:24 PM, Jos Koot jos.k...@gmail.com wrote:

 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:* jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] *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 base phase. The namespace’s identifier mapping (see Namespaces) 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 jos.k...@gmail.com:

 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 racket-users+unsubscr...@googlegroups.com.
 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 racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
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 racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


RE: [racket-users] namespace-undefine-variable! question

2015-08-27 Thread Jos Koot
Of course there are easier methods, yours included. (I used the method of
defining a new language years ago to implement a lazy lambda-calculus, it
should be in the archives of this user's list)
 
What I now have is a toy meta-circular interpreter consisting of one single
symbolic expression acceptable to both racket/base and the interpreter
itself, using racket/base as bootstrap. My toy language does not include
define-forms.(it does include multiple values and makes no distinction
between syntactic and variable bindings; it has some crude tools to define
new hygienic macros; It includes a curry-option that automatically curries
procedure calls and even syntactic forms; I am working on a version that
includes a lazy-option, even for for the expr in (set! var expr))  I have
tested the metacircularity to 5 levels deep. Earlier experience has shown
me that an interpreter may seem metacircular to some levels but then fails
at one level deeper.
 
My interpreter includes a trace option (something like debug in DrRacket,
but much simpler and simply printing the process of evaluation). For this
trace-option I need the same parameter for all levels of meta-circularity,
or otherwise the trace-option can enter an infinite printing loop (for
example when tracing a printer procedure attached as prop:custom-write to a
struct-type). Therefore I use a parameter from a base-namespace that allows
disabling tracing at all levels of metacircularity, but have to hide it
from the user. That's why I want to undefine some variables of the base-
namespace I use to borrow variables crom racket/base. Of cource I could use
a parameter defined outside the interpreter itself, but I want my
interpreter to be written within the intersection of its own language and
racket/base. I don't want my interpreter to depend on a parameter defined
outside the interpreter itself, for in this way the interpreter would not
realy be metacircular. I also want my interpreter to correctly handle
syntaxes and procedures coming from a dictinct instance of the module that
defines the interpreter. Therefore it is important that I import a
parameter from a base-namespace for disabling tracing. (it remains possible
to fool my interpreter, though)
 
As I said, it is just a toy and certainly has no value as a languag for
real life programs. In addition, my interpreter does not obey the principle
of the distinction between expansion, compilation and run-time phases of
Racket. A key principle in my interprreter is that tthere is no distinction
between expansion and run time: the name of a syntacic form is bound as a
variable during the evaluation. This may be very wrong, but I am just
playing around.
 
Thanks for your comment, Jos
 
 

  _  

From: Deren Dohoda [mailto:deren.doh...@gmail.com] 
Sent: jueves, 27 de agosto de 2015 20:19
To: Jos Koot
Cc: Jens Axel Søgaard; Racket-Users List
Subject: Re: [racket-users] namespace-undefine-variable! question


Hi Jos,
But some of them I want to undefine.

Isn't it easier to make your own restricted #lang and then use make-module-
evaluator? Sorry to butt in.


Deren


On Thu, Aug 27, 2015 at 1:24 PM, Jos Koot jos.k...@gmail.com wrote:



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: jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] 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 base phase. The namespace’s identifier mapping (see Namespaces) 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 jos.k...@gmail.com:



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 (λ