all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: taylanbayirli@gmail.com (Taylan Ulrich Bayırlı/Kammer)
To: "Thompson, David" <dthompson2@worcester.edu>
Cc: guix-devel <guix-devel@gnu.org>
Subject: Re: Some macros to make package definitions prettier
Date: Wed, 25 Feb 2015 21:54:26 +0100	[thread overview]
Message-ID: <87k2z567b1.fsf@taylan.uni.cx> (raw)
In-Reply-To: <CAJ=RwfaVe-7Q5gV-487NeWD_TBhiWZA8jrUaeyhoo12yXZV8ZA@mail.gmail.com> (David Thompson's message of "Wed, 25 Feb 2015 12:04:31 -0500")

"Thompson, David" <dthompson2@worcester.edu> 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

  parent reply	other threads:[~2015-02-25 20:54 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 16:42 Some macros to make package definitions prettier Taylan Ulrich Bayırlı/Kammer
2015-02-25 17:04 ` Thompson, David
2015-02-25 17:06   ` Thompson, David
2015-02-25 19:27     ` Taylan Ulrich Bayırlı/Kammer
2015-02-25 20:54   ` Taylan Ulrich Bayırlı/Kammer [this message]
2015-02-25 18:12 ` Andreas Enge
2015-02-25 19:46   ` Taylan Ulrich Bayırlı/Kammer
2015-02-25 20:24   ` Thompson, David
2015-02-25 23:32 ` Ludovic Courtès
2015-02-26 11:07   ` Taylan Ulrich Bayırlı/Kammer
2015-02-26 21:39     ` Ludovic Courtès
2015-03-03 16:49       ` Taylan Ulrich Bayırlı/Kammer
2015-03-03 20:44         ` Ludovic Courtès
2015-03-03 22:47           ` Taylan Ulrich Bayırlı/Kammer
2015-03-04  9:52             ` Ludovic Courtès
2015-02-26 21:41     ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k2z567b1.fsf@taylan.uni.cx \
    --to=taylanbayirli@gmail.com \
    --cc=dthompson2@worcester.edu \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.