guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Some macros to make package definitions prettier


From: Andreas Enge
Subject: Re: Some macros to make package definitions prettier
Date: Wed, 25 Feb 2015 19:12:17 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hello,

thanks for sharing your suggestions!

On Wed, Feb 25, 2015 at 05:42:23PM +0100, Taylan Ulrich Bayırlı/Kammer wrote:
>   (delete foo)
>   (replace bar 'x)
>   (add-before baz pre-baz 'y)) ;=> ((bar . x) (pre-baz . y) (baz . 2))
> This has the following advantages:
> - The order in which the phases are modified is top-down, where in our
>   current style it's bottom-up which both distracts (IMO), and one may
>   forget, as the chain grows and one forgets that it's indeed just a
>   chain of function calls like (foo (bar (baz x))).
> - Indentation doesn't keep growing as one adds more modifications.

Actually, I do not like the imperative, non-functional style of these
syntax rules. For me, they rather obscure what is happening.

The indentation is just a question of style; in my first recipes, I did not
indent consecutive modifications of phases, which was just as readable,
I think (but this only works if you indent manually, and people disliked
the unorthodox (non-)indentation).

> (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")))
>     ...))

That looks actually quite useful to me.

The general drawback of such syntax rules is that newcomers do not see all
the inner cogwheels of the system. So on one hand, one gains that contributing
packages becomes easier; on the other hand, understanding what is actually
happening becomes harder, and also learning scheme through guix becomes more
difficult as we move to our own domain specific language.

Andreas




reply via email to

[Prev in Thread] Current Thread [Next in Thread]