From: Jean Rene Dawin <jdawin@math.uni-bielefeld.de>
To: Roel Janssen <roel@gnu.org>
Cc: guile-user@gnu.org
Subject: Re: Difference when calling guile script from C vs interpreter
Date: Wed, 21 Oct 2020 13:32:21 +0200 [thread overview]
Message-ID: <20201021113221.GA27981@math.uni-bielefeld.de> (raw)
In-Reply-To: <2f0278dd3fe46bcd9ae4b79b2ba466bea857ef8a.camel@gnu.org>
Hi,
thanks for your responses.
> It's generally preferable to *extend* Guile with C code, rather than to *embed* it in C code.
> This means you turn your C code into libraries, which are turned into Guile modules, then you write a Guile program
> that uses those modules. I.e. you call to C code from Guile, not to Guile code from C.
Well, in my case I want my C program to load/compile guile scripts during run time.
The guile scripts are intended to be altered and then reloaded/compiled from within the running C program.
> If you want to really prefer to embed and not extend, then perhaps you can make your Guile files available
> in the %load-path and use scm_primitive_load_path (see documentation).
> Once you've compiled the Guile module, it should be enough to set the
> GUILE_LOAD_COMPILED_PATH environment variable before booting Guile in C
Right. When I use
scm_primitive_load_path(scm_from_locale_string("gp.guile"));
and set the environment variables
GUILE_LOAD_PATH=""
GUILE_LOAD_COMPILED_PATH=""
the code is indeed compiled:
$ ./gp
;;; note: source file gp.guile
;;; newer than compiled /home/.cache/guile/ccache/2.2-LE-8-3.A/home/gp.guile.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling gp.guile
;;; compiled /home/.cache/guile/ccache/2.2-LE-8-3.A/home/gp.guile.go
I'm not sure why the empty environment variables work, because the corresponding variables in guile look like this:
%load-path: ( /usr/share/guile/2.2 /usr/share/guile/site/2.2 /usr/share/guile/site /usr/share/guile)
%load-compiled-path:( /usr/lib/guile/2.2/ccache /usr/lib/guile/2.2/site-ccache)
so my home and .cache directory are not included.
What also works is to give the full path to scm_primitive_load_path and unset the environment variables:
scm_primitive_load_path(scm_from_locale_string("/home/gp.guile"));
$ unset GUILE_LOAD_COMPILED_PATH
$ unset GUILE_LOAD_PATH
$ ./gp
;;; note: source file /home/gp.guile
;;; newer than compiled /home/.cache/guile/ccache/2.2-LE-8-3.A/home/gp.guile.go
;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0
;;; or pass the --no-auto-compile argument to disable.
;;; compiling /home/gp.guile
;;; compiled /home/.cache/guile/ccache/2.2-LE-8-3.A/home/gp.guile.go
For now I'm fine with these solutions. Thanks again.
Regards,
Jean Rene
prev parent reply other threads:[~2020-10-21 11:32 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 12:58 Difference when calling guile script from C vs interpreter Jean Rene Dawin
2020-10-20 14:27 ` Taylan Kammer
2020-10-20 14:37 ` Roel Janssen
2020-10-21 11:32 ` Jean Rene Dawin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201021113221.GA27981@math.uni-bielefeld.de \
--to=jdawin@math.uni-bielefeld.de \
--cc=guile-user@gnu.org \
--cc=roel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).