From mboxrd@z Thu Jan 1 00:00:00 1970 From: Mark H Weaver Subject: Re: Calling functions in `make-flags' Date: Sun, 23 Feb 2014 01:20:47 -0500 Message-ID: <8761o6jqo0.fsf@yeeloong.lan> References: <5307F9D0.8080305@totakura.in> <877g8ntxc6.fsf@netris.org> <530868EA.50508@totakura.in> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:51848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHSQx-0003AY-NI for guix-devel@gnu.org; Sun, 23 Feb 2014 01:21:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WHSQr-0006ci-I9 for guix-devel@gnu.org; Sun, 23 Feb 2014 01:21:03 -0500 Received: from world.peace.net ([96.39.62.75]:49455) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WHSQr-0006cR-EF for guix-devel@gnu.org; Sun, 23 Feb 2014 01:20:57 -0500 In-Reply-To: <530868EA.50508@totakura.in> (Sree Harsha Totakura's message of "Sat, 22 Feb 2014 10:07:54 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Sree Harsha Totakura Cc: guix-devel Sree Harsha Totakura writes: > Can you explain why my earlier code did not work? Your earlier code was: > (arguments > '(#:make-flags '((string-append "SH=" (which "sh"))) The expression immediately following "#:make-flags" is evaluated to produce the list of make flags. In this case, that expression is: '((string-append "SH=" (which "sh"))) The single-quote at the beginning means that this is a literal expression. In other words, it inhibits evaluation of all nested forms within, and simply returns the following datum: ((string-append "SH=" (which "sh"))) i.e. a list containing one element: (string-append "SH=" (which "sh")) which is a list whose first element is the symbol 'string-append', whose second element is the string "SH=", etc. What you want it to return is something like this: ("SH=/nix/store/1bjqv56slfsgpfs0dngj9zww1mx9ikny-bash-4.2/bin/sh") In other words, you need it to evaluate (string-append "SH=" ...) instead of returning that code as a data structure. One way to do this is to use (list (string-append "SH=" ...)). Whereas the single-quote inhibits evaluation of all forms within, 'list' is a normal procedure that evaluates its arguments before combining the results into a list. Another way is to use quasiquote (`), and to unquote (,) the inner expressions that you'd like to evaluate: `(,(string-append "SH=" ...)) In this case, I think the quasiquote doesn't add much readability, but it's a matter of taste I suppose. As for why 'which' didn't work, I suspect it's because this code is evaluated very early in the build process, before the PATH variable has been set. You can use 'which' in the code segments passed to #:phases because those are wrapped with 'lambda', which defines an anonymous procedure. The procedure returned by that lambda expression is not called until it's time to run the phase. At that point, PATH is set. Does that make sense? Regards, Mark