[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] loading libraries is polluting my toplevel namespace

From: felix winkelmann
Subject: Re: [Chicken-users] loading libraries is polluting my toplevel namespace
Date: Sun, 19 Dec 2004 11:26:33 +0100

On Sat, 18 Dec 2004 10:04:22 -0500, Michele Simionato
<address@hidden> wrote:
> It seems that by default external definitions are always loaded at the 
> toplevel.
> For instance if I do
> (let ()
>   (require 'srfi-1)
>   (print fold)
>   )
> (print fold) ; is defined even here
> 'fold' is imported at the toplevel and not inside the let scope. The
> same happens
> with load and require-extension.

Yes. Chicken only has one toplevel namespace, and defining
global values will modify that toplevel namespace. load/require
do not load source (in this case): they load compiled code, which would have
tp be treated completely differently, if it was to be properly enclosed
in a lexical scope.

> It is something I don't like very much. Is there any workaround to keep my
> toplevel clean? I think I asked something similar in the past; also,
> it there any
> way to access the list of the names defined in a library? Something like
> (get-exported-names 'my-library).

No, sorry. For the former problem, you can use psyntax modules,
but that requires (if used with compiled code) that `import' can
find a source-file of the same name as the imported module. It will
expand the source file and register any module- and syntax-information in

> BTW, since I am asking, suppose I have a source file with a
> (declare (unit 'my-library)) declaration and that I compile it with csc -s;
> then I do the same for the same source file without the declaration:
> it seems I can import the resulting .so file in both cases without
> problems, so what's the difference?

This shouldn't work at all. Are you using `load' or `load-library'
for this?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]