[Top][All Lists]

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

RE: Guile truly embedable ?

From: John Fitzgerald
Subject: RE: Guile truly embedable ?
Date: Tue, 8 May 2001 09:26:16 +1200

Deploying Guile on MS-Windows is problematical (see previous postings), but
I shall give it a try when I get back to my Linux machine.  

However, I would have thought that where '(use-modules ...)' is used as I
have done, the symbol would have been defined in the top level environment
and that both 'gh_lookup()' and '(defined? ...)' would also be operating in
that environment.  Your change log comment seems to imply this is not so.

I have included below a test case so you can see exactly what I'm doing and
because it may be easier for you to test at the moment than me.

> -----Original Message-----
> From: Marius Vollmer [SMTP:address@hidden
> Sent: May 08, 2001 06:16
> To:   John Fitzgerald
> Cc:   'address@hidden'
> Subject:      Re: Guile truly embedable ?
> John Fitzgerald <address@hidden> writes:
> > But beware that gh_lookup() returns SCM_UNDEFINED for symbols defined
> with
> > 'define-public' in modules included via 'use-modules', whereas
> > gh_eval_str("(defined? ...)") *will* find them, at least in Guile 1.4.
> Believed fixed.  Can you check it?
> 2001-05-07  Marius Vollmer  <address@hidden>
>       * gh_data.c (gh_lookup): Call gh_module_lookup with
>       `scm_current_module ()', not `#f'.
>       (gh_module_lookup): Expect a module instead of an obarray as first
>       argument and do lookup in that module.
        FILE: foo.scm

        (define-module (foo))

        (define-public (baz) "M41")

        FILE: bar.scm

        (use-modules (foo))

        FILE: test.c

        #include <stdio.h>
        #include <guile/gh.h>

        void main_prog (int argc, char** argv) {
            int bound, defined;

            /* File 'bar.scm' uses 'foo.scm' which defines 'baz'. */
            if (gh_scm2bool(gh_eval_file("bar.scm"))) {
                printf("\tFile 'bar.scm' loaded successfully.\n");

                /* Check what gh_lookup() says. */
                bound = !SCM_UNBNDP(gh_lookup("baz"));
                if (bound)
                    printf("\tSCM_UNBNDP(gh_lookup(\"baz\")) says
                    printf("\tSCM_UNBNDP(gh_lookup(\"baz\")) says

                /* Check what (defined? ...) says. */
                defined = gh_scm2bool(gh_eval_str("(defined? 'baz)"));
                if (defined)
                    printf("\t(defined? 'baz) says defined.\n");
                    printf("\t(defined? 'baz) says undefined.\n");

                /* Report on their agreement. */
                if (bound == defined)
                    printf("\tgh_lookup() and (defined? ...) agree.
                    printf("\tgh_lookup() and (defined? ...) disagree.
            } else {
                printf("\tCould not load file 'bar.scm'.\n");

        int main (int argc, char** argv) {
            gh_enter(argc, argv, main_prog);
            return 0;

NOTICE: The information contained in this electronic mail message and any
attachments is confidential to Pavilion Technologies, Inc. or one of its
subsidiaries and may contain proprietary information or be legally
privileged. This message and any attachments are intended only for the
personal and confidential use of the designated recipient(s). If you are not
the intended recipient or an agent responsible for delivering it to the
intended recipient, you are hereby notified that you have recieved this
message in error, and that any review, dissemination, distribution or
copying of this message and any attachments is unauthorized and strictly
prohibited. If you have received this message in error, please notify me
immediately by telephone and electronic mail, and delete this message, any
attachments, and all copies thereof. Thank you very much  

reply via email to

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