[plt-scheme] Namespace problems...
On Jan 28, Paulo Jorge de Oliveira Cantante de Matos wrote:
> It won't work, namespace-variable-value is not working as I
> would like. This won't work:
>
> (module test mzscheme
>
> (define (hah-foo)
> (display "foo"))
>
> ((namespace-variable-value 'hah-foo #t))
>
> )
It tries to pull out a value for a global `hah-foo', for whatever
happens to be the current namespace. Module variables are best
thought of as any other bound names -- they have no name. To solve
it, you can use the namespace after it is initialized like this:
(eval '(define (hah-foo) ...))
or slightly better:
(namespace-set-variable-value! 'hah-foo (lambda () ...))
but then you can see that this is basically using the namespace only
for its hash-table-like property, so it is better to just use a hash
table. With very basic syntax, you can make it look like definitions.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!