guix-devel
[Top][All Lists]
Advanced

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

Re: A better way to access records.


From: Brendan Tildesley
Subject: Re: A better way to access records.
Date: Fri, 13 Nov 2020 22:24:32 +1100

On 1/11/20 8:01 am, Ludovic Courtès wrote:
Hi,

Brendan Tildesley <mail@brendan.scot> skribis:

In the guix codebase, on many occasions there appear things like this:

(match-lambda
     (($ <agetty-configuration> agetty tty term baud-rate auto-login
         login-program login-pause? eight-bits? no-reset? remote?
flow-control?
         host no-issue? init-string no-clear? local-line extract-baud?
         skip-login? no-newline? login-options chroot hangup?
keep-baud? timeout
         detect-case? wait-cr? no-hints? no-hostname? long-hostname?
         erase-characters kill-characters chdir delay nice extra-options)
      (list
       ....
This has officially been Bad Practice for a while.  Instead, the
recommended approach is to use ‘match-record’ from (guix records).
There are examples of that primarily in (gnu services …).

Does that help?

Thanks,
Ludo’.

I suppose It makes sense that one would want to be explicit about names in a source code file.

BTW, if that is the recommended way, would someone with an understanding of the records.scm code mind adding support for delayed & thunked fields in match-record? There is a TODO there. I wouldn't know how to do it.




reply via email to

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