From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: P Pareit Newsgroups: gmane.lisp.guile.user Subject: Re: [guile/scwm] 2nd argument problem to scm_definedp() Date: Tue, 17 Sep 2002 11:25:17 +0200 Sender: guile-user-admin@gnu.org Message-ID: <200209171125.17679.pieter.pareit@planetinternet.be> References: <200209162049.54095.pieter.pareit@planetinternet.be> <87sn09lo1i.fsf@zagadka.ping.de> NNTP-Posting-Host: localhost.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Trace: main.gmane.org 1032255187 14866 127.0.0.1 (17 Sep 2002 09:33:07 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 17 Sep 2002 09:33:07 +0000 (UTC) Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 17rEjB-0003rd-00 for ; Tue, 17 Sep 2002 11:33:05 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rEcV-0007Td-00; Tue, 17 Sep 2002 05:26:11 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17rEb4-00075O-00 for guile-user@gnu.org; Tue, 17 Sep 2002 05:24:42 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17rEaY-00073F-00 for guile-user@gnu.org; Tue, 17 Sep 2002 05:24:41 -0400 Original-Received: from riker.skynet.be ([195.238.3.89]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17rEaX-000732-00 for guile-user@gnu.org; Tue, 17 Sep 2002 05:24:09 -0400 Original-Received: from localhost.localdomain (196.91-136-217.adsl.skynet.be [217.136.91.196]) by riker.skynet.be (8.11.6/8.11.6/Skynet-OUT-2.20) with ESMTP id g8H9Nrf19711 for ; Tue, 17 Sep 2002 11:23:53 +0200 (MET DST) (envelope-from ) Original-To: guile-user@gnu.org User-Agent: KMail/1.4.2 In-Reply-To: <87sn09lo1i.fsf@zagadka.ping.de> Errors-To: guile-user-admin@gnu.org X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.lisp.guile.user:1001 X-Report-Spam: http://spam.gmane.org/gmane.lisp.guile.user:1001 On Monday 16 September 2002 09:42 pm, Marius Vollmer wrote: > P Pareit writes: > > The c-code that modifies %load-path looks like creating %load-path > > in stead of adding strings to %load-path. > > Can you show that code? > /* in a header */ #define SCWM_VAR(cvar, name) \ do { pscm_ ## cvar =3D SCM_CDRLOC( \ scm_sysintern0(name) ); } while (0) /* in a source file */ void init_scwm_load_path() { SCM *pscm_pct_load_path; SCM path; SCWM_VAR(pct_load_path,"%load-path"); /** The internal compiled-in loading path for scwm. */ path =3D *pscm_pct_load_path; path =3D gh_cons(gh_str02scm(SCWM_LOAD_PATH),path); path =3D gh_cons(gh_str02scm(SCWM_BIN_LOAD_PATH),path); path =3D scm_internal_parse_path(getenv("SCWM_LOAD_PATH"), path); *pscm_pct_load_path =3D path; } SCWM_LOAD_PATH and SCWM_LOAD_PATH get set by cpp to things like=20 "/usr/local/share/scwm/modules". > > I would first like to know if %load-path is > > already defined, in scheme code this would be: (and (defined? %load-p= ath) > > (display "%load-path is defined") (newline)), it seems I cannot get t= he > > argument for _current_lexical_environment_ right: > > If you want to default an optional argument from C, use SCM_UNDEFINED: > > if (SCM_NFALSEP (scm_definedp (load_path_symbol, SCM_UNDEFINED))) > ... > > I guess you want the default. If not, things get messy. The lexical > environment that definedp expects is the data structure that gets > passed as the second argument to macro transformers. Yes, I want the default. I was trying to do do something like this: (set! %load-path (cons "/usr/.../modules" %load-path)) in c-code to repla= ce=20 the code given. But I run into the same problems with my code: [ppareit@localhost mkhk]$ ./test -c "(display %load-path) (newline)" (/usr/local/share/scwm/modules . #) [ppareit@localhost mkhk]$ cat main.c #include #include void init_load_path(void) { SCM path; path =3D scm_c_lookup("%load-path"); path =3D scm_cons(scm_makfrom0str("/usr/local/share/scwm/modules"), path); scm_c_define("%load-path", path); } void inner_main(void* closure, int argc, char** argv) { init_load_path(); scm_shell(argc, argv); } int main(int argc, char* argv[]) { scm_boot_guile(argc, argv, inner_main, NULL); } I must also note that I did not find documentation on scm_makfrom0str(),=20 except on what I found in the header files. The reason that I'm using scm= _*()=20 instead of the original gh_*() functions is because they are no longer=20 supported so whenever I have to change something I use the scm_* interfac= e. It seems I have a problem to get the value of an scheme variable in c-cod= e=20 right now. pieter; _______________________________________________ Guile-user mailing list Guile-user@gnu.org http://mail.gnu.org/mailman/listinfo/guile-user