[plt-scheme] namespace-variable-value
I hope you don't mind some more questions on this...Why doesn't
namespace-variable-value pick up the mapping in the current-namespace?
Wayne
On Fri, Apr 27, 2007 at 08:26:02PM +0200, jos koot wrote:
> Hi Wayne
> Is this what you want?
>
> (module lang1 mzscheme
> (provide (all-defined)
> (all-from mzscheme))
> (define f 1))
>
> (module test1 lang1
> (provide (all-defined))
> (define (test1)
> (printf "~s~n"
> (namespace-variable-value 'f #t (lambda () 'undefined)
> (module->namespace 'lang1)))))
>
> (require test1)
> (test1) ; display 1
>
> (module lang2 mzscheme (provide (all-from mzscheme)))
>
> (module test2 lang2
> (provide (all-defined))
> (define (test2)
> (printf "~s~n"
> (namespace-variable-value 'f #t (lambda () 'undefined)
> (module->namespace 'lang2)))))
>
> (require test2)
> (test2) ; --> display undefined
>
> Jos
>
> ((((lambda(x)((((((((x x)x)x)x)x)x)x)x))
> (lambda(x)(lambda(y)(x(x y)))))
> (lambda(x)(x)x))
> (lambda()(printf "Greetings, Jos~n"))))
> ----- Original Message -----
> From: support at taxupdate.com
> To: jos koot
> Cc: plt-scheme at list.cs.brown.edu
> Sent: Friday, April 27, 2007 2:37 PM
> Subject: Re: [plt-scheme] namespace-variable-value
>
>
> Jos,
>
> On Fri, Apr 27, 2007 at 07:30:26PM +0200, jos koot wrote:
> > Module level variables can be assigned to only by the module itself. In this way the writer of a module is assured that the user
> of
> > the module cannot corrupt the variables.
>
> It's not clear to me whether this answers the question I'm trying to ask. Here's
> the original code:
>
> (module lang mzscheme
> (provide (all-defined)
> (all-from mzscheme))
> (define f 1))
>
> (module test lang
> (provide (all-defined))
> (provide (all-from lang)
> (define (test1)
> (display (namespace-variable-value 'f))))
>
> (require test)
> (test1)
>
> I don't want to set a module-level variable outside of the module, I want
> to test whether it has been defined. I expected the namespace-variable-value
> call to use mapping (the default) to see that f has been imported. Am I
> misunderstanding how namespace-variable-value works?
>
> Wayne