From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.user Subject: Re: Strange error from %search-load-path via include-from-path when parameter is not a literal string Date: Mon, 17 Oct 2011 17:54:06 -0400 Message-ID: <87vcrnp9mp.fsf@yeeloong.netris.org> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1318888479 23692 80.91.229.12 (17 Oct 2011 21:54:39 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 17 Oct 2011 21:54:39 +0000 (UTC) Cc: guile-user@gnu.org To: Ian Hulin Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Oct 17 23:54:36 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 1RFv8l-00045t-Pb for guile-user@m.gmane.org; Mon, 17 Oct 2011 23:54:35 +0200 Original-Received: from localhost ([::1]:58523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFv8g-0003Ul-2g for guile-user@m.gmane.org; Mon, 17 Oct 2011 17:54:30 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:38609) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFv8d-0003UV-3h for guile-user@gnu.org; Mon, 17 Oct 2011 17:54:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RFv8b-0001wH-VN for guile-user@gnu.org; Mon, 17 Oct 2011 17:54:27 -0400 Original-Received: from world.peace.net ([96.39.62.75]:55811) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RFv8b-0001w8-LI for guile-user@gnu.org; Mon, 17 Oct 2011 17:54:25 -0400 Original-Received: from 209-6-55-18.c3-0.smr-ubr1.sbo-smr.ma.cable.rcn.com ([209.6.55.18] helo=yeeloong.netris.org) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1RFv8V-0000j9-KR; Mon, 17 Oct 2011 17:54:19 -0400 Original-Received: from mhw by yeeloong.netris.org with local (Exim 4.72) (envelope-from ) id 1RFv8I-0004VQ-O6; Mon, 17 Oct 2011 17:54:06 -0400 In-Reply-To: (Ian Hulin's message of "Mon, 17 Oct 2011 19:20:45 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 96.39.62.75 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:8899 Archived-At: Ian Hulin writes: > I'm trying to write a V2/V1 compatible function like the following: > > (define (ly:include the-file) > (if (string>? (version) "1.9.10") > (include-from-path the-file) > (load-from-path the-file))) The problem is that `include' and `include-from-path' are not procedures, but syntactic constructs that actually replace themselves with the contents of the included file at macro-expansion time. Among other things, this allows you to include a file into a local lexical environment, e.g. if "foo.scm" contains "(define test 5)" then the following procedure will return 5, and `test' will become a local variable within `foo': (define (foo) (include "foo.scm") test) Since `include' and `include-from-path' is performed at macro-expansion time, obviously its parameter must be a literal string at macro-expansion time. Therefore, you can't use it from a procedure as you attempted, but you could make a macro instead: (define-syntax ly:include (if (string>? (version) "1.9.10") (syntax-rules () ((_ fn) (include-from-path fn))) (syntax-rules () ((_ fn) (load-from-path fn))))) Best, Mark