From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Neil Jerram" Newsgroups: gmane.lisp.guile.devel Subject: Re: RFD: drop the GH interface. Date: Mon, 22 Sep 2008 22:12:39 +0200 Message-ID: <49dd78620809221312n56644763xcd34610dfbfba971@mail.gmail.com> References: <87wshgl5sd.fsf@gnu.org> <871vzhho7c.fsf@gnu.org> <48D26E19.5000301@gnu.org> <49dd78620809210240r6a426487xdb893b55519f8ccd@mail.gmail.com> <668c430c0809211102i701b3d40o37643bf6713fe28@mail.gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1222114403 32576 80.91.229.12 (22 Sep 2008 20:13:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 22 Sep 2008 20:13:23 +0000 (UTC) Cc: guile-devel@gnu.org To: "Bruce Korb" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Sep 22 22:14:20 2008 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KhrnP-00057v-R4 for guile-devel@m.gmane.org; Mon, 22 Sep 2008 22:14:16 +0200 Original-Received: from localhost ([127.0.0.1]:44017 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KhrmD-00032L-0q for guile-devel@m.gmane.org; Mon, 22 Sep 2008 16:12:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KhrmA-00032F-Kg for guile-devel@gnu.org; Mon, 22 Sep 2008 16:12:54 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Khrm7-00031S-Rk for guile-devel@gnu.org; Mon, 22 Sep 2008 16:12:54 -0400 Original-Received: from [199.232.76.173] (port=53910 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Khrm7-00031P-OD for guile-devel@gnu.org; Mon, 22 Sep 2008 16:12:51 -0400 Original-Received: from rv-out-0708.google.com ([209.85.198.241]:43322) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Khrm3-0005Pc-7b for guile-devel@gnu.org; Mon, 22 Sep 2008 16:12:51 -0400 Original-Received: by rv-out-0708.google.com with SMTP id k29so1986753rvb.6 for ; Mon, 22 Sep 2008 13:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=HWsfaZAl/0Ox+yNy2E16posvntTG4quO+GpTerCHpmI=; b=nzKEivyF6eR09euiOZDxXac3SmsoQS8zXAH3UIcTCuetLU9TNk4oFuuDBloZ4ow6s+ LRvz+R88oiDLH+D881MHMdW5Aiwk0pbnZmukQA3/QTlmn2Kxp2I0GJ30QiVULKamFtF0 LcZnmSxQ/yBYrAySRHJkXNLQ1hmf7ntd+jk7s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=O5Zx9mEdfq8CuYLThIEulVRs2gqcMLapEgFnfk/5h3taEcd5UfDG7aab5CjE0nOfk7 ksEfGsrzhTmmJuxBlVGR7Nr1GziP5lhNmQRWtLHi92m8i05A2xZJ6FiRap6SrVAur3Za Yj0i/cErutiAbVc3O+Dn41ZDEVymrfM4SNrlI= Original-Received: by 10.141.141.3 with SMTP id t3mr2244555rvn.124.1222114359576; Mon, 22 Sep 2008 13:12:39 -0700 (PDT) Original-Received: by 10.140.142.15 with HTTP; Mon, 22 Sep 2008 13:12:39 -0700 (PDT) In-Reply-To: <668c430c0809211102i701b3d40o37643bf6713fe28@mail.gmail.com> Content-Disposition: inline X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:7738 Archived-At: 2008/9/21 Bruce Korb : > > On a slightly unrelated question, are there any pending changes that would make > the following code obsolete? I've hated using it ever since I wrote > it, but I still > do not know of any reasonable alternative. > > Thank you. Regards, Bruce > > SCM > ag_scm_c_eval_string_from_file_line( char const * pzExpr, char const * > pzFile, int line ) [...] There aren't any pending changes that would make this code obsolete. But there is a little something that Guile has supported for a while, called Scheme. Seriously, though. The whole point of Guile is to allow people to write more Scheme and less C, and your C code could be written much more easily in Scheme: (define (ag-eval-string-from-file-line expr file line) (with-input-from-string expr (lambda () (set-port-filename! (current-input-port) file) (set-port-line! (current-input-port) line) (set-port-column! (current-input-port) 0) (let loop ((ans *unspecified*) (x (read))) (if (eof-object? x) ans (loop (primitive-eval x) (read))))))) As far as I know, everything there has been in place and stable since the start of 1.6. So, the reason the libguile API doesn't include functions that are complex compositions of more primitive APIs, such as your ag_scm_c_eval_string_from_file_line(), is that such compositions are supposed to be done in Scheme instead. I think the Scheme above is way clearer than the C. Also, once you're in Scheme, it's way easier to add further bells and whistles, such as more intelligent error handling. For a real example of that, see the block of code beginning `((eval)' in ice-9/gds-client.scm (currently line 353). What do you think? Could autogen do this in Scheme instead of in C? Regards, Neil