[plt-scheme] namespace-variable-value

From: jos koot (jos.koot at telefonica.net)
Date: Fri Apr 27 14:26:02 EDT 2007

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


((((lambda(x)((((((((x x)x)x)x)x)x)x)x))
    (lambda(x)(lambda(y)(x(x y)))))
  (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


  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 
  > 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)

  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?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20070427/acd78e98/attachment.html>

Posted on the users mailing list.