Label duplicates David Van Horn 18 Jan 2005 17:01 UTC
From the SRFI document:
A list of field labels is associated with the record type <type name>,
obtained by appending from left to right the lists of field labels of any
record type schemes (see below) appearing in the <type clause>, followed by
the list of labels in the <constructor clause>, followed by the labels in
order of appearance in the <field clause>s. Duplicates are removed from the
resulting list according to the semantics of delete-duplicates of SRFI-1.
It's not clear from this paragraph that it is an error to have duplicates
within the constructor clause or among the field clauses. That is, the
following should be an error (and indeed it is according to the reference
implementation), but is arguably a legal record type definition according to
the prose above:
(define-record-type box make-box box? (v) (v))
On a related note, I don't know what to make of this:
(define-record-type box (make-box v v) box?)
I would think this should be an error as well, but is not according to the
reference implementation. Accepting this as a legal record definition leads
to the following ambiguity:
(define-record-type box (make-box v v) box? (v unbox))
(unbox (make-box 1 2)) => 1 or 2?
The reference implementation gives 1 (in PLT), but as far as I can tell this
is unspecified according to the SRFI.