[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

srfi-9 record type checking

From: Kevin Ryde
Subject: srfi-9 record type checking
Date: Wed, 07 Jun 2006 09:19:15 +1000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

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)
      (f1 get-f1 set-f1)
      (f2 get-f2 set-f2))

    (define-record-type bar
      (make-bar b1 b2)
      (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?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]