From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Smith Newsgroups: gmane.lisp.guile.user Subject: Re: Using guile as an extension language for GNU make Date: Sun, 18 Sep 2011 15:28:00 -0400 Organization: GNU's Not Unix! Message-ID: <1316374080.28907.163.camel@homebase> References: <1316304616.28907.118.camel@homebase> <87wrd5x404.fsf@ambire.localdomain> Reply-To: psmith@gnu.org NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1251" Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1316374095 3206 80.91.229.12 (18 Sep 2011 19:28:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 18 Sep 2011 19:28:15 +0000 (UTC) Cc: guile-user@gnu.org To: Thien-Thi Nguyen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Sun Sep 18 21:28:11 2011 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1R5N29-0001Ps-7Z for guile-user@m.gmane.org; Sun, 18 Sep 2011 21:28:09 +0200 Original-Received: from localhost ([::1]:35966 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5N28-00052H-Gy for guile-user@m.gmane.org; Sun, 18 Sep 2011 15:28:08 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:49825) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R5N25-00051w-ML for guile-user@gnu.org; Sun, 18 Sep 2011 15:28:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R5N24-000692-5R for guile-user@gnu.org; Sun, 18 Sep 2011 15:28:05 -0400 Original-Received: from oproxy8-pub.bluehost.com ([69.89.22.20]:41718) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1R5N23-00068w-Uf for guile-user@gnu.org; Sun, 18 Sep 2011 15:28:04 -0400 Original-Received: (qmail 7648 invoked by uid 0); 18 Sep 2011 19:28:02 -0000 Original-Received: from unknown (HELO box531.bluehost.com) (74.220.219.131) by oproxy8.bluehost.com with SMTP; 18 Sep 2011 19:28:02 -0000 Original-Received: from 146-115-71-23.c3-0.lex-ubr1.sbo-lex.ma.cable.rcn.com ([146.115.71.23] helo=[172.31.1.105]) by box531.bluehost.com with esmtpsa (SSLv3:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1R5N22-0004Tn-An; Sun, 18 Sep 2011 13:28:02 -0600 In-Reply-To: <87wrd5x404.fsf@ambire.localdomain> X-Mailer: Evolution 2.32.2 X-Identified-User: {678:box531.bluehost.com:madscie1:mad-scientist.us} {sentby:smtp auth 146.115.71.23 authed with paul+mad-scientist.us} X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 69.89.22.20 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:8803 Archived-At: On Sun, 2011-09-18 at 17:30 +0200, Thien-Thi Nguyen wrote: > The double-quote stripping is kind of hacky. I would create a port > and =91display=92 the result of =91scm_c_eval_string=92 to it. Thanks for the hints. I've reworked my code to implement a generic "SCM to make string" function; currently it looks like this: char * cvt_scm_to_str (SCM obj) { char *str; =20 if (scm_is_bool (obj) && scm_is_true (obj)) str =3D xstrdup ("t"); else if (scm_is_number (obj) || scm_is_string (obj) || scm_is_sym= bol (obj)) { SCM port =3D scm_open_output_string (); =20 scm_display (obj, port); str =3D scm_to_locale_string (scm_get_output_string (port)); scm_close_output_port (port); } else str =3D xstrdup (""); =20 return str; } That's better than what I had before, but I still have some concerns. For example, what if a Guile call wanted to return a list? I can use display as above, but the list will be enclosed in parentheses, which is not how make displays lists. Is there a clean way to handle this? I could write a function then invoke it with scm_map() (right?) but this seems like it might be work. Also what if the data structure is more complex, where some elements of the list are lists themselves, etc.? I can "flatten" the entire thing out, I suppose. Or I could ignore them as above and require the Guile scripting to convert the list into a string before returning it. --=20 ---------------------------------------------------------------------------= ---- Paul D. Smith Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.net "Please remain calm...I may be mad, but I am a professional." --Mad Scient= ist