From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: mark@markwitmer.com Newsgroups: gmane.lisp.guile.user Subject: Re: Issue with compiling to scheme Date: Tue, 13 Aug 2013 14:09:21 -0400 Message-ID: <87bo51xy26.fsf@markwitmer.com> References: <874nb7evbo.fsf@markwitmer.com> <87vc3mlmun.fsf@gmail.com> <87a9knt5do.fsf@zigzag.favinet> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1376417343 20723 80.91.229.3 (13 Aug 2013 18:09:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Aug 2013 18:09:03 +0000 (UTC) To: guile-user@gnu.org Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Tue Aug 13 20:09:05 2013 Return-path: Envelope-to: guile-user@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V9J1j-0004kB-D1 for guile-user@m.gmane.org; Tue, 13 Aug 2013 20:09:03 +0200 Original-Received: from localhost ([::1]:52896 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9J1i-0005Br-TH for guile-user@m.gmane.org; Tue, 13 Aug 2013 14:09:02 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9J1P-00053w-UV for guile-user@gnu.org; Tue, 13 Aug 2013 14:08:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V9J1K-00079H-3N for guile-user@gnu.org; Tue, 13 Aug 2013 14:08:43 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:59078) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V9J1J-00078l-TC for guile-user@gnu.org; Tue, 13 Aug 2013 14:08:38 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1V9J1H-0004OM-Gy for guile-user@gnu.org; Tue, 13 Aug 2013 20:08:35 +0200 Original-Received: from cpe-184-58-115-186.woh.res.rr.com ([184.58.115.186]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Aug 2013 20:08:35 +0200 Original-Received: from mark by cpe-184-58-115-186.woh.res.rr.com with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 13 Aug 2013 20:08:35 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 56 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: cpe-184-58-115-186.woh.res.rr.com User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:GBc1DvC1wWcK0IxUc9YcXFWwCAI= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 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:10629 Archived-At: Thien-Thi Nguyen writes: > Maybe the simplest way is to completely separate code generation from > compilation. This also gives you an opportunity to do compilation in > two places (of the code that generates the code, and of the generated > code). So your Makefile would look like: > > gen: gen.scm > $(COMPILE) -o $@ $(COMPILEFLAGS) $< > chmod +x gen > > %.generated : %.xml > ./gen -o $@ $(GENFLAGS) $< > > %.go : %.generated > $(COMPILE) -o $@ $(COMPILEFLAGS) $< That's kind of what I wound up doing via abuse of the language's #:read property. Instead of providing a function that just gives the result of xml->sxml to the compiler, I have it break some xml tags into multiple tags so each one can be treated as a separate expression. Eg. The file looks like this: And the reader would return each of the following expressions in turn: '(xcb (@ (header "xproto"))) '(xcb-2 (@ (header "xproto"))) '(struct (@ (name "struct"))) That way the tag gets compiled into the (define-module ...) expression and the fictitious tag gets compiled into the (begin ...) statement that contains some module-wide definitions and so forth. This approach stays inside of the guile 2 compiler infrastructure but it has the disadvantage of turning what's supposed to be a simple, single-purpose function into a bit of a stateful mess. It would be nice if the compiler could handle multiple-value returns from read-and-parse (assuming that doesn't harm performance... I might try it out and see what it does). > I am very much looking forward to learning what you discover, and > applying it to all the projects i maintain. (For example, Guile-SDL > test/gfx.scm is a dog under Guile 2.x, blech.) Fingers crossed... I'll be happy to do that if I come up with something! Thanks -- Mark Witmer