multiple definitions due to include/load
What about if definitions are included/loaded multiple times due to (use-)dependencies of Gambit-C 4 source files? E.g. if lib1.scm uses lib2.scm, and bar.scm uses lib1.scm *and* lib2.scm, then lib2.scm is used twice by bar.scm: directly and indirectly (i.e. via lib1.scm). Of course lib1.scm should not rely on such applications, e.g. there might be foo.scm which just uses lib1.scm, but *not* lib2.scm. C programmers like to avoid multiple includes by protecting headers by that well known pattern: /* this is file lib2.h */ #ifndef _LIB2_ #define _LIB2_ ... #endif Gauche Scheme has something which sounds related (quoted from the manual): | -- Function: provide feature | Adds FEATURE to the system's provided feature list, so that the | subsequent `require' won't load the same file again. LaTeX does similiar: compare \providecommand and \newcommand. Is there a simple way for Gambit? Or doesn't it matter at all? (Why not?) Regards Thomas
Afficher les réponses par date
At 23:09 Uhr +0100 05.02.2006, Thomas Hafner wrote:
What about if definitions are included/loaded multiple times due to (use-)dependencies of Gambit-C 4 source files?
I've written chjmodule for this. Is there something particular you are missing from it? I still want to change it (asap) to give faster imports/exports (and make the "standard-"/"extended-bindings" declarations work, and fix my old reimport bug), and to provide an easy way to build a (standalone) executable. Christian.
On Mon, Feb 06, 2006 at 02:19:56AM +0100, Christian wrote:
I've written chjmodule for this. Is there something particular you are missing from it?
No, I just ignored the existence of chjmodule, for I filtered out the related e-mails of the mailing list. (I think it's a human attitude: as long as someone does not have the problem, he's not yet ready to see/accept the solution. I've already been on both sides of this situation: on the helping one and on the one to be helped.) Thanks Thomas -- ___ http://hafner.sdf-eu.org/ ___ ___ mailto:thomas _______________ ___________ @hafner.nl.eu.org ___
On Sun, Feb 05, 2006 at 11:09:14PM +0100, Thomas Hafner wrote:
Is there a simple way for Gambit? Or doesn't it matter at all? (Why not?)
SLIB seems to provide that in a simple way (sorry for not having found it earlier). Here follows an example. Content of file ~/homecat: ;; -*-scheme-*- ( (lib2 . "~/share/gambc/lib2") ) Content of file ~/share/gambc/lib2.scm: (define (lib2:hello) (display "Hello from lib2!") (newline)) gsi session: > (require 'lib2) > (lib2:hello) Hello from lib2! > (require 'lib2) #t > (lib2:hello) Hello from lib2! > (I don't say it's *better* than Christian's chjmodule, but for me it's *simpler*, because SLIB is already available but chjmodule had to be installed first.) Regards Thomas -- ___ http://hafner.sdf-eu.org/ ___ ___ mailto:thomas _______________ ___________ @hafner.nl.eu.org ___
participants (3)
-
Christian -
Thomas Hafner -
Thomas Hafner