unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Nala Ginrut <nalaginrut@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Subject: Re: The r6rs record-type in pattern matching of Guile-3.0
Date: Tue, 15 Sep 2020 20:15:27 +0800	[thread overview]
Message-ID: <CAPjoZoe7NOEWg3GrSQGck0B4hgD5_=cr9P6=xtN5BuqteN2GJw@mail.gmail.com> (raw)
In-Reply-To: <CAPjoZocQsiaiWXZiyFCbjqM9kAucETauSehMmWzSAEiD+T1fJg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2423 bytes --]

To whom may care this issue.
According to the discussion in IRC, here's the memo for the issue, in case
anybody encounter the same issue again:

The record is not nested inherited anymore, this would be the permanent
change.
The good thing is better performance to access record-type, the bad thing
is the incompatibility.
If anyone use pattern-matching for parsing parent of a record-type, then
it'll break.

There are probably two workarounds to keep your current code if you use
pattern-matching for parsing parent.
1. Copy and maintain the old record code:
 (rnrs records procedural) and (rnrs records syntactic) from
73d0a3bccb3c2b79d7f0e3aaca88a84f3a5c3f43

2. The r6rs record-type is powerful so that you may customize it by
redefine its constructor to always put its parent to the first field.
So that pattern-matching can correctly parse the parent in its assumed
first field.

From 3.0, you can't bind the parent of record type in the same matching
case, the parent (super class) would be is-A relationship,
not the previous has-A relationship, so that the parent (super class) is
not nested in the record-type anymore. The inherited fields
are the parts of the record-type (subclass) from now on, which would be
faster for access, obviously.

Best regards.


On Tue, Aug 25, 2020 at 4:16 AM Nala Ginrut <nalaginrut@gmail.com> wrote:

> Hi folks!
> I found the r6rs record pattern matching has different results compared to
> Guile-2.
> Here is the example code:
>
>
> -----------------------------------------code--------------------------------------
> ,use (rnrs)
> ,use (ice-9 match)
>
> (define-record-type aaa (fields a))
> (define-record-type bbb (parent aaa) (fields b))
> (define r (make-bbb 1 2))
>
> (match r
>   (($ bbb ($ aaa _ a) b) (list a b))
>   (else "no"))
> ;; ==> "no"  in Guile-3
> ;; ===> (1 2) in Guile-2
>
> (match r
>   (($ bbb a b) (list a b))
>   (else "no"))
> ==> (1 2)  in Guile-3
> ==> (<aaa> 2) in Guile-2
>
> --------------------------------------------end----------------------------------------------
>
> In Guile-2, we have to specify the parent record-type for binding the
> fields of the parent, but it seems not in Guile-3.0.
> I know Guile-3 had tweaked record-type to unify the low-level
> implementation.
>
> My question: Is this the new expected activity? Do we have to tweak all
> record type matching since Guile-3 ?
> Or maybe it's just a bug?
>
> Best regards.
>
>

[-- Attachment #2: Type: text/html, Size: 3316 bytes --]

      reply	other threads:[~2020-09-15 12:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-24 20:16 The r6rs record-type in pattern matching of Guile-3.0 Nala Ginrut
2020-09-15 12:15 ` Nala Ginrut [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAPjoZoe7NOEWg3GrSQGck0B4hgD5_=cr9P6=xtN5BuqteN2GJw@mail.gmail.com' \
    --to=nalaginrut@gmail.com \
    --cc=guile-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).