[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] Legacy caar to cddddr
On Mon, 24 Oct 2011, Alex Shinn wrote:
> I'd be interested to see real-world examples of (set-car! (c[ad]{3,}r x) y).
> My guess is these are examples of abusing lists as records.
Whether to call this an abuse is very subjective, depending very much on the
type system you are imposing in your mind on your Scheme program.
In my opinion, lists provide a wonderfully elegant representation
of anonymous product types a la Hindley-Milner. They have the additional
advantage that you can portably READ and WRITE them and debug them easily,
whereas records require a bunch of annoying boilerplate to do this.
As for which composite selectors should be provided by default, I agree with
yout that one can probably suppress some of the selectors deeper than the spine
of the list. But maybe one could expand the number of selectors along the
spine itself. I have often run into the following:
(define binding-type car)
(define binding-name cadr)
(define binding-levels caddr)
(define binding-mutable? cadddr)
(define (binding-dimension b) (car (cddddr b))) ; UGLY
The last line is not a tragedy, but it is ugly. Also, some optimizing
implementations might be able to provide random access to more
than 4 initial elements of short lists.
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports