unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: guile-devel@gnu.org
Subject: Re: Functional record "setters", a different approach
Date: Thu, 08 Nov 2012 20:09:26 +0100	[thread overview]
Message-ID: <87625fdi8p.fsf@gnu.org> (raw)
In-Reply-To: 87r4o47k00.fsf@tines.lan

Hi Mark!

Mark H Weaver <mhw@netris.org> skribis:

> I've attached a slightly improved functional record "setters" patch.
> The only change since yesterday's version is to the test suite, which
> now includes tests of the compile-time error checking.

Nice, thanks!

It addresses my main concern with the previous version of the patch,
which is that it lacked support for named setters, so that’s great.

At the time you were concerned about the “weight” of these macros.  Are
you just more relaxed now, or do you have a psyntax optimization in the
pipeline?  :-)

> +                          (make-address "Foo" "Paris" "France"))))
> +      (and (equal? (set-fields p
> +                     ((person-email) "bar@example.com")
> +                     ((person-address address-country) "Spain")
> +                     ((person-address address-city) "Barcelona"))

The choice of towns seems inaccurate.  ;-)

> +    (pass-if "set-fields with one path as a prefix of another"
> +      (let ()
> +        (define-immutable-record-type foo (make-foo x) foo?
> +          (x foo-x)
> +          (y foo-y set-foo-y)
> +          (z foo-z set-foo-z))
> +
> +        (define-immutable-record-type :bar (make-bar i j) bar?
> +          (i bar-i)
> +          (j bar-j set-bar-j))
> +
> +        (catch 'syntax-error
> +         (lambda ()
> +           (compile '(let ((s (make-bar (make-foo 5) 2)))
> +                       (set-fields s
> +                         ((bar-i foo-x) 1)
> +                         ((bar-i foo-z) 2)
> +                         ((bar-i) 3)))
> +                    #:env (current-module))
> +           #f)
> +         (lambda (key whom what src form subform)
> +           (equal? (list key whom what form subform)
> +                   '(syntax-error set-fields
> +                                  "one field path is a prefix of another"
> +                                  (set-fields s
> +                                    ((bar-i foo-x) 1)
> +                                    ((bar-i foo-z) 2)
> +                                    ((bar-i) 3))
> +                                  (bar-i)))))))))

You might want to use ‘pass-if-equal’ here, for better reporting.

Please commit, I’ll take care of the doc.

Thanks!

Ludo’.




  reply	other threads:[~2012-11-08 19:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-11  6:59 Functional record "setters", a different approach Mark H Weaver
2012-04-11  7:57 ` Mark H Weaver
2012-04-11  8:20   ` Mark H Weaver
2012-04-11 22:27     ` Ludovic Courtès
2012-04-11 22:22 ` Ludovic Courtès
2012-04-12 15:04   ` Mark H Weaver
2012-04-12 16:45     ` Thien-Thi Nguyen
2012-04-12 19:58     ` Ludovic Courtès
2012-04-13  1:58       ` Mark H Weaver
2012-04-13 15:41         ` Ludovic Courtès
2012-04-13 17:26           ` Mark H Weaver
2012-05-07 16:34         ` Ludovic Courtès
2012-05-14 22:25           ` Mark H Weaver
2012-05-15 21:23             ` Ludovic Courtès
2012-11-07 20:04 ` Mark H Weaver
2012-11-08  5:15   ` Mark H Weaver
2012-11-08 19:09     ` Ludovic Courtès [this message]
2012-11-09  3:54       ` Mark H Weaver
2012-11-10 16:28         ` Ludovic Courtès
2012-11-10 19:03           ` Mark H Weaver
2012-11-10 21:40             ` Ludovic Courtès
2012-11-10  4:13       ` Mark H Weaver

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=87625fdi8p.fsf@gnu.org \
    --to=ludo@gnu.org \
    --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).