From mboxrd@z Thu Jan 1 00:00:00 1970 From: iyzsong@member.fsf.org (=?utf-8?B?5a6L5paH5q2m?=) Subject: Re: Change defaults of 'define-record-type*' need invalidate auto-compilation caches Date: Mon, 08 Jan 2018 20:49:58 +0800 Message-ID: <87vagcikg9.fsf@member.fsf.org> References: <87shbjm3yd.fsf@member.fsf.org> <87o9m7m3es.fsf@member.fsf.org> <87po6khc0o.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52721) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYWsU-0005He-Di for guix-devel@gnu.org; Mon, 08 Jan 2018 07:50:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYWsR-0007Pq-83 for guix-devel@gnu.org; Mon, 08 Jan 2018 07:50:10 -0500 In-Reply-To: <87po6khc0o.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 08 Jan 2018 11:37:27 +0100") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hi! > > iyzsong@member.fsf.org (=E5=AE=8B=E6=96=87=E6=AD=A6) skribis: > >> [...] >> >> Only with '--fresh-auto-compile' or delete the cache of x.scm, I will >> get the output "y". >> >> Is this a bug? > > It=E2=80=99s a feature. :-) > > Namely, default value resolution happens at macro-expansion time: > > scheme@(guile-user)> ,use(guix records) > scheme@(guile-user)> (define-record-type* > foo make-foo foo? > (x foo-x (default "x"))) > > scheme@(guile-user)> ,expand (foo) > $2 =3D (let* ((x "x") > (s ((@@ (srfi srfi-9) allocate-struct) 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!