[Top][All Lists]

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

Re: srfi-9 vs make-record-type

From: John Cowan
Subject: Re: srfi-9 vs make-record-type
Date: Sun, 21 Jul 2019 15:21:14 -0400

On Sun, Jul 21, 2019 at 6:21 AM Christopher Lam <address@hidden>

In experiments converting legacy code to use srfi-9 records, I'm finding
> the latter doesn't travel well across modules.

In SRFI 9 you need to define a record type in exactly one module and then
export whatever subset of the constructor, predicate, accessors, and
mutators (not typically the record type name) that you want to make
visible.  Other modules can then import those names.  This is because calls
on define-record-type are generative (SRFI 9 doesn't say so, but in
practice they are), so a particular record type should be defined only once.

In my code, I often export the predicate and accessors, but not the
constructor or mutators.  Then I export a factory method that may or may
not call the constructor.

It may be convenient to define the record-type in its own module.

John Cowan        address@hidden
Promises become binding when there is a meeting of the minds and
is exchanged. So it was at King's Bench in common law England; so it was
under the common law in the American colonies; so it was through more than
two centuries of jurisprudence in this country; and so it is today.
       --Specht v. Netscape

reply via email to

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