On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

I'm trying to use the record #:parent property to refactor some code. I'm unable to use the parent property of a record, what is the proper usage of this property?

(define-record-type <particle>
  (make-particle)
  particle?
;; omitted)
(define-record-type <prop>   
#:parent <particle>
(make-prop) 
prop?
;; omitted)

The define-record-type procedure is from SRFI-9. The #:parent propery applies to make-record-type which is a lower-level Guile specific. The define-record-type does not accept a #:parent keyword.


There is also a define-record-type in R6RS which has a (parent ...). See https://www.gnu.org/software/guile/manual/html_node/R6RS-Records.html


If this is confusing, it's because after R6RS was published, Scheme splintered and grew in different directions; Guile lisp supports all these directions at the same time. You can read http://dpk.io/r7rswtf if you are interested in the history.

The parent property appears in the guile hoot documentation. And it is in the the guile hoot records.scm file.

So I guess that I'm using the wrong definition, I will try to import the proper definition.  I already tried (hoot records) to no success. 

The parent property appears under make-record-type, not define-record-type.

https://www.gnu.org/software/guile/manual/html_node/Records.html

Hoot's `define-record-type`, which is in (hoot records), supports parent types. The `define-record-type` exposed in `(scheme base)` conforms to R7RS-small and does not support additional flags like #:parent.

(1 edit) (+1)

Oops! I did not realize. @mirkohd must have been using that version then.

Records that can be subtyped must be marked as #:extensible. See this unit test of records for an example: https://gitlab.com/spritely/guile-hoot/-/blob/main/test/test-records.scm?ref_typ...

I haven't actually used this feature for myself, yet. I hope it works okay!