[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Change defaults of 'define-record-type*' need invalidate auto-compil
From: |
宋文武 |
Subject: |
Re: Change defaults of 'define-record-type*' need invalidate auto-compilation caches |
Date: |
Mon, 08 Jan 2018 20:49:58 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Hi!
>
> address@hidden (宋文武) skribis:
>
>> [...]
>>
>> Only with '--fresh-auto-compile' or delete the cache of x.scm, I will
>> get the output "y".
>>
>> Is this a bug?
>
> It’s a feature. :-)
>
> Namely, default value resolution happens at macro-expansion time:
>
> scheme@(guile-user)> ,use(guix records)
> scheme@(guile-user)> (define-record-type* <foo>
> foo make-foo foo?
> (x foo-x (default "x")))
>
> scheme@(guile-user)> ,expand (foo)
> $2 = (let* ((x "x")
> (s ((@@ (srfi srfi-9) allocate-struct) <foo> 1)))
> ((@@ (srfi srfi-9) struct-set!) s 0 x)
> s)
>
> That way, we can check at macro-expansion time that all the required
> fields are present, which is nice.
>
> The downside is what you write: that everything that uses the record
> type must be recompiled when it is changed (IOW, the record type is part
> of the ABI).
>
> HTH!
Get it, thanks for the explanation!