[gambit-list] more problems with blackhole

Per Eckerdal per.eckerdal at gmail.com
Mon May 18 06:29:39 EDT 2009


> In the following code, what I'm trying to understand is ...
>
> why does the namespace seem to treat functions and macros  
> separately? In particular, there does not seem to be anyway for me  
> to access 'bar' in test2 once I (export)
> > foo
> *** ERROR IN (console)@2.1 -- Unbound variable: ~#foo
> 1> bar
> *** ERROR IN (console)@3.1 -- Unbound variable: ~#bar
> 2> test2#foo
> #<procedure #2 test2#foo>
> 2> test2#bar
> *** ERROR IN (console)@5.1 -- Unbound variable: test2#bar

Functions and macros are treated separately because they are a  
different thing. The reason that test2#foo works, but not test2#bar is  
that foo is an actual variable, while test2#bar is a macro, which is  
not in the Gambit runtime. BH does all macro expansion, including  
resolving all variables to fully qualified names. If the user writes a  
fully qualified name, BH ignores it.

Another way to explain it is to say that the fact that the test2  
module gets the test2# namespace is a "coincidence"; BH will try to  
choose a namespace that is similar to the name of the module, but in  
by design it could choose any namespace. It chooses a similar one to  
make it easier to understand stack traces and similar. (In the current  
version, it will in fact always choose the same namespace as the  
module name, but that's a bug and is the next thing I will fix)

The reason the namespace#variable is allowed at all is for debugging;  
if you get an error message regarding a certain function, the function  
name you get from Gambit will be fully qualified. That way you could  
type in the fully qualified name in the REPL and access it.

Any use of namespace#variable notation in BH is to be used for hacking  
purposes only, because there is no guarantee that a module will have  
the same namespace on two different machines. The hygienic macro  
facilities of BH remove the need for this notation. It is still useful  
when messing around with the REPL though.

/Per




More information about the Gambit-list mailing list