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]

Re: scm_sysintern vs scm_intern


The hobbit compiler has the same problem, since it needs to be able to
connect C variables to the locations holding the values of top level
symbols.

The current hobbit release (1.3.2) has some problems with this
process, but I have found a better solution, which goes as follows:

The C macro

    #define intern(x) \
    SCM_CDR(\
    scm_eval_0str(\
    "(or (module-variable (current-module) '" x ")"\
    "    (module-make-local-var! (current-module) '" x "))"\
    ))

takes a string containing a name and returns a pointer to the
corresponding defining vcell. So the code

    load_func = &SCM_CDR(intern("load"))

will make load_func be a pointer to the lambda defining `load', such
that you could do something like:

    scm_apply(*load_func,<some appropriate collection of SCM values>)


Bernard Urban has independently fixed the same problem for the
upcoming release of hobbit, and it is quite possible that his solution
is cleaner, but the above does seem to work.


---------------------------+--------------------------------------------------
Christian Lynbech          | Telebit Communications A/S                       
Fax:   +45 8628 8186       | Fabrikvej 11, DK-8260 Viby J
Phone: +45 8628 8177 + 28  | email: chl@tbit.dk --- URL: http://www.telebit.dk
---------------------------+--------------------------------------------------
Hit the philistines three times over the head with the Elisp reference manual.
                                        - petonic@hal.com (Michael A. Petonic)