From: Kevin Ryde <user42@zip.com.au>
Subject: srfi-9 record type checking
Date: Wed, 07 Jun 2006 09:19:15 +1000 [thread overview]
Message-ID: <873behlvnw.fsf@zip.com.au> (raw)
Speaking of srfi-9 records (Ludovic on guile-user), I notice the spec
calls for an accessor used on a wrong type record to be an error but
currently guile returns #f for that. Eg.
(use-modules (srfi srfi-9))
(define-record-type foo
(make-foo f1 f2)
foo?
(f1 get-f1 set-f1)
(f2 get-f2 set-f2))
(define-record-type bar
(make-bar b1 b2)
bar?
(b1 get-b1 set-b1)
(b2 get-b2 set-b2))
(define f (make-foo 1 2))
(pk (get-b1 f))
I guess `define-record-type' should be making a stricter procedure
than `record-accessor' gives.
I got bitten by this using `record-accessor' the other day. For some
reason I thought it had strict type checking and scratched my head for
a while until realizing I was passing a wrong record and getting back
#f. Is that #f a feature? Would there be scope to add an option to
ask for a strict checking version? Or make that the default?
_______________________________________________
Guile-devel mailing list
Guile-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-devel
next reply other threads:[~2006-06-06 23:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-06 23:19 Kevin Ryde [this message]
2006-06-07 16:42 ` srfi-9 record type checking Ludovic Courtès
2006-06-07 22:18 ` Neil Jerram
2006-06-07 23:21 ` Kevin Ryde
2006-06-08 7:14 ` Ludovic Courtès
2006-06-12 23:00 ` Neil Jerram
2006-06-13 7:26 ` Ludovic Courtès
2006-08-02 0:42 ` Kevin Ryde
2006-08-22 9:37 ` Ludovic Courtès
2006-08-25 1:04 ` Kevin Ryde
2006-06-07 23:31 ` Kevin Ryde
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=873behlvnw.fsf@zip.com.au \
--to=user42@zip.com.au \
/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).