[r6rs-discuss] Record Types

From: Ludovic Courtès <ludovic.courtes>
Date: Tue, 07 Aug 2007 09:53:15 +0200

Hi,

Brian Jaress <brian_jaress at gna.org> writes:

> Without record types, you'd probably have a definition somewhere like:
>
> (define (add value weight)
> ;something)
>
> With 5.97 record types, it would be:
>
> (define (add value weight-accessor)
> ;something)

This is similar to SRFI-9 records and to built-in types: you usually
don't pass accessors around to procedures; instead, procedures that need
it are expected to import the modules that define `container-weight',
`vector-ref', `car', etc. This seems consistent to me.

> I'd like to see records handled like vectors, but with symbols instead
> of numbers:
>
> (record-ref record 'field)
> (record-set! record 'field value)

Interestingly, this was the approach taken by SRFI-35, although one of
its authors is also the author of SRFI-9. I didn't find any clue in the
list archive as to why named fields were preferred over accessors.
Maybe because it allows for very loose connections between the module
that instantiates a condition and the one that handles it?

Thanks,
Ludovic.
Received on Tue Aug 07 2007 - 03:53:15 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC