From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: Change defaults of 'define-record-type*' need invalidate auto-compilation caches Date: Mon, 08 Jan 2018 11:37:27 +0100 Message-ID: <87po6khc0o.fsf@gnu.org> References: <87shbjm3yd.fsf@member.fsf.org> <87o9m7m3es.fsf@member.fsf.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]:35472) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eYUoB-00019B-4L for guix-devel@gnu.org; Mon, 08 Jan 2018 05:37:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eYUo7-0003H0-5c for guix-devel@gnu.org; Mon, 08 Jan 2018 05:37:35 -0500 Received: from hera.aquilenet.fr ([2a0c:e300::1]:59970) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eYUo6-0003GP-U7 for guix-devel@gnu.org; Mon, 08 Jan 2018 05:37:31 -0500 In-Reply-To: <87o9m7m3es.fsf@member.fsf.org> (=?utf-8?B?IuWui+aWh+atpiIn?= =?utf-8?B?cw==?= message of "Sat, 06 Jan 2018 23:07:39 +0800") 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: =?utf-8?B?5a6L5paH5q2m?= Cc: guix-devel@gnu.org Hi! iyzsong@member.fsf.org (=E5=AE=8B=E6=96=87=E6=AD=A6) skribis: > For example, in the current directory, I have 'foo.scm': > > (define-module (foo) > #:use-module (guix records) > #:export (foo foo-x)) > > (define-record-type* > foo make-foo foo? > (x foo-x (default "x"))) > > > > And 'x.scm': > > (use-modules (foo)) > (display (foo-x (foo))) > > > Run 'guile -L . x.scm', will output "x". > > Then I change the '(default "x")' to '(default "y")' in foo.scm, and > re-run 'guile -L x.scm', it still output "x", I would expect it to > change to "y". > > 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: --8<---------------cut here---------------start------------->8--- 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) --8<---------------cut here---------------end--------------->8--- 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! Ludo=E2=80=99.