From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:57173) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h7SGE-0002mm-6r for guix-patches@gnu.org; Fri, 22 Mar 2019 18:03:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h7S7B-0000Oj-0G for guix-patches@gnu.org; Fri, 22 Mar 2019 17:54:16 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41258) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h7S70-0000G5-5P for guix-patches@gnu.org; Fri, 22 Mar 2019 17:54:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h7S6z-0001Yu-U6 for guix-patches@gnu.org; Fri, 22 Mar 2019 17:54:01 -0400 Subject: [bug#34948] [PATCH 1/3] records: Allow thunked fields to refer to 'this-record'. Resent-Message-ID: References: <20190322172120.10974-1-ludo@gnu.org> <20190322172719.11199-1-ludo@gnu.org> From: Ricardo Wurmus In-reply-to: <20190322172719.11199-1-ludo@gnu.org> Date: Fri, 22 Mar 2019 22:53:07 +0100 Message-ID: <87y35660fw.fsf@elephly.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 34948@debbugs.gnu.org Ludovic Court=C3=A8s writes: > * guix/records.scm (this-record): New syntax parameter. > (make-syntactic-constructor)[wrap-field-value]: When F is thunked, > return a one-argument lambda instead of a thunk, and parameterize > THIS-RECORD. So the value of the thunked field is no longer strictly a thunk? I=E2=80=99m having difficulties understanding how this works. Why does the =E2=80=9Cthunked field=E2=80=9D now require an argument (=E2=80=9Cx=E2=80= =9D)? We use the syntax parameter =E2=80=9Cthis-record=E2=80=9D to introduce a ne= w binding with this name in the context of the =E2=80=9Cvalue=E2=80=9D of the field. = The parameter value is =E2=80=A6 hard to make out. How does the syntax-case ma= cro in the following syntax-parameterize expression evaluate to the record itself? Would #,x not be sufficient to refer to the argument of the field accessor? > (define (wrap-field-value f value) > (cond ((thunked-field? f) > - #`(lambda () #,value)) > + #`(lambda (x) > + (syntax-parameterize ((this-record > + (lambda (s) > + (syntax-case s () > + (id > + (identifier? #'id) > + #'x))))) -- Ricardo