[Top][All Lists]

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

Re: srfi-9 vs make-record-type

From: Christopher Lam
Subject: Re: srfi-9 vs make-record-type
Date: Mon, 13 Jul 2020 13:07:23 +0000

As part of preparation for compatibility with guile-3, we've changed
gnucash's use of make-record-type to define-record-type.
Since the record field getters and setters are not exportable across
modules, we've used the following forms.

(define-record-type :record
 (make-record field1 field2)
 (field1 field1-getter field1-setter)
 (field2 field2-getter field2-setter))
(define-public gnc:field1-getter field1-getter)
(define-public gnc:field1-setter field1-setter)
(define-public gnc:field2-getter field2-getter)
(define-public gnc:field2-setter field2-setter)

There may be a more elegant solution but for now it'll do. See the set of
related commits at

On Mon, 26 Aug 2019 at 12:20, Christopher Lam <>

> Thank you Mark and John.
> On Mon, 5 Aug 2019 at 18:18, Mark H Weaver <> wrote:
>> The problem here is that 'make-person' is a macro.  Macros are expanded
>> at compile time, and must therefore be available at compile time.
>> When you compile 'm2.scm', those macros are not available, because
>> 'load' only has effects at run-time, by design.  Since there is no macro
>> definition for 'make-person' at compile-time, Guile's compiler generates
>> code that assumes it will be a procedure.
>> In summary, you cannot use 'load' to import macros from another module.
>> > For various reasons I must keep (load "module.scm") mechanism
>> If you can share those reasons, perhaps I can help you find another
>> solution.
> The only reason is that I've started cleaning up numerous modules in
> GnuCash written about 20 years ago, and the hyper-modular approach is too
> difficult to try unravel for now. So, I've converted records to srfi-9
> wherever possible (i.e. used internally), and left the exported ones alone.
> This one was a fun one to fix:
> ;-)

reply via email to

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