l...@gnu.org (Ludovic Courtès) writes: > Hi! > > iyzs...@member.fsf.org (宋文武) 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!