From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: ludo@gnu.org (Ludovic =?iso-8859-1?Q?Court=E8s?=) Newsgroups: gmane.lisp.guile.devel Subject: Re: srfe records in reworked match Date: Wed, 21 Apr 2010 13:47:48 +0200 Message-ID: <87d3xtgh7f.fsf@gnu.org> References: <201004201514.18375.stefan.tampe@spray.se> <878w8hkxky.fsf@gnu.org> <07487229-BEA5-49C8-B73F-83370F028513@spray.se> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1271851627 6570 80.91.229.12 (21 Apr 2010 12:07:07 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 21 Apr 2010 12:07:07 +0000 (UTC) Cc: guile-devel@gnu.org To: Stefan Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Apr 21 14:07:05 2010 connect(): No such file or directory Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1O4Yht-00064W-FT for guile-devel@m.gmane.org; Wed, 21 Apr 2010 14:07:05 +0200 Original-Received: from localhost ([127.0.0.1]:39569 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4Yhs-0002dj-Hs for guile-devel@m.gmane.org; Wed, 21 Apr 2010 08:07:04 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4YPN-0004Bp-50 for guile-devel@gnu.org; Wed, 21 Apr 2010 07:47:57 -0400 Original-Received: from [140.186.70.92] (port=40617 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4YPL-0004AG-9M for guile-devel@gnu.org; Wed, 21 Apr 2010 07:47:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4YPJ-0007bq-0u for guile-devel@gnu.org; Wed, 21 Apr 2010 07:47:55 -0400 Original-Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]:14783) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4YPI-0007bb-It for guile-devel@gnu.org; Wed, 21 Apr 2010 07:47:52 -0400 X-IronPort-AV: E=Sophos;i="4.52,250,1270418400"; d="scan'208";a="57415435" Original-Received: from laptop-147-210-128-170.labri.fr (HELO nixey) ([147.210.128.170]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES128-SHA; 21 Apr 2010 13:47:50 +0200 In-Reply-To: <07487229-BEA5-49C8-B73F-83370F028513@spray.se> (Stefan's message of "Wed, 21 Apr 2010 12:26:40 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 2 =?iso-8859-1?Q?Flor=E9al?= an 218 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Key-ID: 0xEA52ECF4 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 83C4 F8E5 10A3 3B4C 5BEA D15D 77DD 95E2 EA52 ECF4 X-OS: x86_64-unknown-linux-gnu X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10277 Archived-At: Hi, [Keeping the list CC=E2=80=99d.] Stefan writes: > Question? should we make it lean and just allow sfri-9 or perhaps > allow for both styles of records? Actually, record matching in Wright=E2=80=99s match assumes users follow a simple naming convention for the type predicate (only for the type predicate in fact, not for accessors as I thought before.) Then it also assumes to be able to access record fields directly (e.g., with (struct-ref x n)), not through field accessors. This part is in theory specific to a given record implementation, though in practice Guile=E2=80=99s records and SRFI-9 implementations can both be accessed as = raw structs with zero-indexed fields: --8<---------------cut here---------------start------------->8--- scheme@(guile-user)> (eq? (struct-ref (current-module) 0) (module-obarray (= current-module))) $2 =3D #t scheme@(guile-user)> (use-modules (srfi srfi-9)) scheme@(guile-user)> (define-record-type foo (make-foo x y) foo? (x foo-x)(= y foo-y)) scheme@(guile-user)> (let ((x (make-foo 'x 'y))) (eq? (foo-x x) (struct-ref= x 0))) $3 =3D #t --8<---------------cut here---------------end--------------->8--- (Guile also has other record types: SRFI-35 error conditions, GOOPS objects, and R6RS records, which Julian recently implemented in the =E2=80=98wip-r6rs-libraries=E2=80=99 branch. There might be others floatin= g around, who knows. ;-)) [...] >> As noted in Shinn=E2=80=99s match-cond-expand.scm, this record matching = form is >> not ideal: >>=20 >> ;; Annoying unhygienic record matching. Record patterns look like >> ;; ($ record fields...) >> ;; where the record name simply assumes that the same name suffixed >> ;; with a "?" is the correct predicate. >>=20 >> Thanks! >>=20 >> Ludo=E2=80=99. > > Exactly what do you mean by unhygien. (The excerpt above is by Alex Shinn.) It=E2=80=99s unhygienic in the sense that it introduces a reference to a bi= nding that is to be looked up at the point where the macro is expanded, and which may or may not be bound. (See for an intro on this topic.) Right below, Shinn writes: ;; Why not just require the "?" to begin with?! Indeed, requiring users to enter the record type predicate, instead of the record type name, would make the macro hygienic, and would be just as convenient: (match x (($ foo? x y) (list x y))) Thanks, Ludo=E2=80=99.