From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Rene Dawin Newsgroups: gmane.lisp.guile.user Subject: Re: Difference when calling guile script from C vs interpreter Date: Wed, 21 Oct 2020 13:32:21 +0200 Message-ID: <20201021113221.GA27981@math.uni-bielefeld.de> References: <20201020125840.GA14718@math.uni-bielefeld.de> <2f0278dd3fe46bcd9ae4b79b2ba466bea857ef8a.camel@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10403"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.9.4 (2018-02-28) Cc: guile-user@gnu.org To: Roel Janssen Original-X-From: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Wed Oct 21 13:42:20 2020 Return-path: Envelope-to: guile-user@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kVCVV-0002XP-LE for guile-user@m.gmane-mx.org; Wed, 21 Oct 2020 13:42:17 +0200 Original-Received: from localhost ([::1]:58848 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVCVU-00082V-Gj for guile-user@m.gmane-mx.org; Wed, 21 Oct 2020 07:42:16 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVCM5-0004oE-T2 for guile-user@gnu.org; Wed, 21 Oct 2020 07:32:35 -0400 Original-Received: from smtp2.math.uni-bielefeld.de ([129.70.45.13]:43356) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVCLz-0005mJ-Pj; Wed, 21 Oct 2020 07:32:30 -0400 Original-Received: from math.uni-bielefeld.de (kvm01.math.uni-bielefeld.de [129.70.45.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by smtp2.math.uni-bielefeld.de (Postfix) with ESMTPSA id 48145602E7; Wed, 21 Oct 2020 13:32:23 +0200 (CEST) Content-Disposition: inline In-Reply-To: <2f0278dd3fe46bcd9ae4b79b2ba466bea857ef8a.camel@gnu.org> Received-SPF: none client-ip=129.70.45.13; envelope-from=jdawin@math.uni-bielefeld.de; helo=smtp2.math.uni-bielefeld.de X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 07:32:23 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane-mx.org@gnu.org Original-Sender: "guile-user" Xref: news.gmane.io gmane.lisp.guile.user:16992 Archived-At: 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