From mboxrd@z Thu Jan 1 00:00:00 1970 From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Subject: Re: Some macros to make package definitions prettier Date: Wed, 25 Feb 2015 21:54:26 +0100 Message-ID: <87k2z567b1.fsf@taylan.uni.cx> References: <874mqa6iz4.fsf@taylan.uni.cx> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQiyU-00069C-Dr for guix-devel@gnu.org; Wed, 25 Feb 2015 15:54:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQiyT-0001tj-BV for guix-devel@gnu.org; Wed, 25 Feb 2015 15:54:30 -0500 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:47037) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQiyT-0001tT-4m for guix-devel@gnu.org; Wed, 25 Feb 2015 15:54:29 -0500 Received: by wggy19 with SMTP id y19so6122830wgg.13 for ; Wed, 25 Feb 2015 12:54:28 -0800 (PST) In-Reply-To: (David Thompson's message of "Wed, 25 Feb 2015 12:04:31 -0500") 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: "Thompson, David" Cc: guix-devel "Thompson, David" writes: >> (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"))) >> ...)) > > I'm not sure I like combining the alist destructuring part of this > macro. IMO, 'phase-lambda' could just take care of the 'lambda*' > boilerplate, and maybe another macro ('alist-let'?) to reduce the > 'assoc-ref' usage. So we have (phase-lambda ((inputs (libx liby)) (outputs (out))) body) vs. something like (phase-lambda (inputs outputs) (alist-let ((inputs (libx liby)) (outputs (out))) body)) which consists of two parts which are principally orthogonal. I suspect that the above combination will be the overwhelming majority of both these macros' use-cases if we split them, meaning we will have done something impractical for the sake of a principle. In fact the above implied definition of `alist-let' is still contrived for this special case; if I really implemented a stand-alone `alist-let', I would probably not make it support multiple clauses like that, meaning the code would look something like: (phase-lambda (inputs outputs) (alist-let inputs (libx lib) (alist-let outputs (out) body))) which is unpleasant. Others who have more experience with the larger codebase of Guix (or even just Scheme codebases in general) should tell me whether my attempt at pragmatism and the "You Ain't Gonna Need It" mentality is mistaken here, but I think the `phase-lambda' that subsumes `alist-let' is the best choice because that will cover our actual use-cases the best. Taylan