Taylan Kammer <taylan.kam...@gmail.com> writes:
> The most feature-rich record system supported by Guile is probably the
> R6RS record system, which is available through the modules:
>
>   (rnrs records syntactic (6))
>   (rnrs records procedural (6))
>   (rnrs records inspection (6))
> Here's a super brief example usage of R6RS records, demonstrating that
> field accessors are defined implicitly, but constructors still use an 
> unnamed sequence of arguments to assign fields:
>
>   (import (rnrs records syntactic (6)))  ; must use 'import' for R6RS
>
>   (define-record-type (cat make-cat cat?) (fields name age color))
>
>   (define garfield (make-cat "Garfield" 42 'orange))
>
>   (cat-color garfield)  ;=>  orange

I did not know about that shorthand — thank you!

I always did this:

(import (srfi srfi-9)) ; define-record-type
(define-record-type <cat>
  (make-cat name age color)
  cat?
  (name cat-name) (age cat-age) (color cat-color))

Compared to that the syntactic form you showed is much nicer.

Is there a difference in efficiency or such?

Best wishes,
Arne
-- 
Unpolitisch sein
heißt politisch sein
ohne es zu merken

Attachment: signature.asc
Description: PGP signature

Reply via email to