unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* srfi-9 record type checking
@ 2006-06-06 23:19 Kevin Ryde
  2006-06-07 16:42 ` Ludovic Courtès
  0 siblings, 1 reply; 11+ messages in thread
From: Kevin Ryde @ 2006-06-06 23:19 UTC (permalink / 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-08-25  1:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-06 23:19 srfi-9 record type checking Kevin Ryde
2006-06-07 16:42 ` 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

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).