guix-devel
[Top][All Lists]
Advanced

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

Re: Layout of ‘define-configuration’ records


From: Ludovic Courtès
Subject: Re: Layout of ‘define-configuration’ records
Date: Wed, 23 Nov 2022 22:56:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:

[...]

>>>> One last thing: placing ‘%location’ first can let us implement:
>>>>
>>>>   (define (configuration-location config)
>>>>     (struct-ref config 0))
>>>
>>> Would this have worked?
>>>
>>> scheme@(gnu services mcron)> (define config (mcron-configuration))
>>> scheme@(gnu services mcron)> (struct-ref 0 config)
>>
>> You got the order wrong.  :-)
>
> Ah!  Thanks for pointing my silly mistake.  Then the argument would
> become... if it's good for define-configuration, it should have been
> good for define-record-type* the same (why the discrepancy?).

‘define-record-type*’ is generic; there’s no reason for it to add a
‘location’ field.

> After your new documentation in place to guide users to DTRT with
> regards to matching records, if you think %location should be the first
> field, then we should make it so in both instances, perhaps?

‘%location’ only appears in ‘define-configuration’; what did you mean by
“both instances”?

> Oops!  Another point to add to our future coding style guidelines :-).

In the end, I guess the lesson is that, indeed, not all the design
choices and rationales are properly documented.  That’ll always be the
case to a large extent though, so changes “close to the core” require
more careful review and discussion to fully understand the implications
of the change—it might look innocuous but have broader implications than
expected.

Thanks,
Ludo’.



reply via email to

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