From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Some macros to make package definitions prettier Date: Thu, 26 Feb 2015 00:32:14 +0100 Message-ID: <87bnkhzhxd.fsf@gnu.org> References: <874mqa6iz4.fsf@taylan.uni.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:54073) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQlRL-0001OT-Qc for guix-devel@gnu.org; Wed, 25 Feb 2015 18:32:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQlRG-0001mE-SA for guix-devel@gnu.org; Wed, 25 Feb 2015 18:32:27 -0500 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:54608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQlRG-0001m9-Pq for guix-devel@gnu.org; Wed, 25 Feb 2015 18:32:22 -0500 In-Reply-To: <874mqa6iz4.fsf@taylan.uni.cx> ("Taylan Ulrich \=\?utf-8\?Q\?\=5C\=22Bay\=C4\=B1rl\=C4\=B1\=2FKammer\=5C\=22\=22's\?\= message of "Wed, 25 Feb 2015 17:42:23 +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: Taylan Ulrich =?utf-8?Q?=22Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer=22?= Cc: guix-devel@gnu.org taylanbayirli@gmail.com (Taylan Ulrich "Bay=C4=B1rl=C4=B1/Kammer") skribis: > (modify-phases '((foo . 0) (bar . 1) (baz . 2)) > (delete foo) > (replace bar 'x) > (add-before baz pre-baz 'y)) ;=3D> ((bar . x) (pre-baz . y) (baz . 2)) I like it! Let=E2=80=99s put it in (guix utils)? > ;;; phase-lambda > > (define-syntax phase-lambda > (syntax-rules () > ((phase-lambda ((arg (alist-entry ...)) > ...) > body ...) > (lambda* (#:key arg ... #:allow-other-keys) > (let-values (((alist-entry ...) > (let ((arg* arg)) > (values > (assoc-ref arg* (symbol->string 'alist-entry)) > ...))) > ...) > body ...))))) > > ;;; Usage example: > > (phase-lambda ((inputs (libx liby)) > (outputs (out))) > ...) > > ;;; effectively equivalent to: > > (lambda* (#:key inputs outputs #:allow-other-keys) > (let ((libx (assoc-ref inputs "libx")) > (liby (assoc-ref inputs "liby")) > (out (assoc-ref outputs "out"))) > ...)) > > > This saves the usual boilerplate of '(#:key inputs outputs > #:allow-other-keys)' and the subsequent `assoc-ref' uses. Clearly, this is something we must address. However, I=E2=80=99m uneasy wi= th this solutions for two reasons: 1. The embedded =E2=80=98symbol->string=E2=80=99, and the fact that the d= eveloper no longer types in "foo" when the =E2=80=98inputs=E2=80=99 field has "foo= " (as a string), making the connection non-obvious. 2. In the grand scheme of things, gexps make the problem moot: (lambda _ (frob-libs #$libx #$liby:include) (stuff-output #$output) ...) However, there=E2=80=99s a complication: currently we can change the =E2=80= =98inputs=E2=80=99 field of a package (like =E2=80=98package-with-explicit-inputs=E2=80=99 etc= . do), and its build script will get to see the new inputs, which is super convenient. Conversely, gexps currently end up hard-coding the output file name of the package directly in the build script, which prevents this kind of =E2=80=9Cinput rewriting.=E2=80=9D I don=E2=80=99t yet have a nice idea on how to solve that, but that=E2=80= =99s an important thing to do. WDYT? Thank you, Ludo=E2=80=99.