This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
>>>>> "thi" == thi <ttn@mingle.glug.org> writes: thi> Bernard URBAN writes: >> The way intern and friends work is also largely mysterious to >> me. Added to module, it is a real nightmare. For the sake of >> hobbit, having intern well explained and a C interface to >> modules would help a lot. If anyone is listening to that... thi> From ghobbit.h, we have thi> #define intern(x,y) scm_permanent_object(scm_intern((x),(y))) This is actually in guile-hobbit-1.3 and above: #define intern(x,y) scm_permanent_object(scm_sysintern0((x))) and something more complex in the case of modules (see below why). In the file libguile/symbols.c, there are also a lot of other "intern" variants, which usefulness is unclear to me. There is also #define intern_symb(x,y) scm_permanent_object(scm_intern((x),(y))) in guilehob.h, and the distinction was necessary until now, but I don't know why. This is a SCM legacy, present since the original hobbit. thi> The function scm_intern() is defined in libguile/symbols.c, thi> and takes symbol name (as char *) and length. The symbol is thi> hashed into obarray `scm_symhash', then bound to a newly thi> created variable. Finaly, the pair thi> (NAME . VALUE) thi> is returned. If the symbol was already in the obarray, its thi> name and value are used immediately (w/o creating a new thi> variable). This is why the alias `my_car' looks at the `cdr' thi> of the call to `intern'. thi> Because the C macro `intern' uses `scm_intern', there is no thi> module interaction; whoever has access to `scm_symhash' can thi> see the symbol/variable. Whether or not this means that thi> hobbit runtime needs to be in the module that sees thi> `scm_symhash' is not known to me. If scm_symhash is only accessed through an intern-like function, it is irrelevant. The basic problem is that in most cases (at least in guile-1.3), you have some useful symbols in some module. You cannot only rely on "intern" to see if a symbol is still defined. Hence the compilation with -m and the macro #ifdef HOBBIT_MODULE, which is a kludge. So the need of a C interface to the module system. -- B. Urban