guile-user
[Top][All Lists]
Advanced

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

records


From: Ian Zimmerman
Subject: records
Date: 26 Mar 2004 15:36:59 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I'd like to use guile's facility of defining record types, instead of
faking it with vectors, but I find it quite inconvenient.  Guile doesn't
directly provide the various functions associated with a record type
(predicate, constructor, accessors, mutators) but only a "record descriptor"
that can be further queried to extract the functions.

This seems to force me to make the record descriptor a global:

(define foo-rtd (make-record-type "foo" 'bar 'baz))
(define foo? (record-predicate foo-rtd))
(define make-foo (record-constructor foo-rtd))
(define foo-bar (record-accessor foo-rtd 'bar))
(define set-foo-bar! (record-modifier foo-rtd 'bar))

Instead, I itch to write

(let ((foo-rtd (make-record-type "foo" 'bar 'baz)))
  (define foo? (record-predicate foo-rtd))
  ...)

but this of course doesn't work because the define is local. 

What is the idiomatic way to do this?

-- 
Nothing can be explained to a stone.
Or to a stoned person, either.




reply via email to

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