[Top][All Lists]

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

Re: overriding car/cdr

From: Marius Vollmer
Subject: Re: overriding car/cdr
Date: Sat, 20 Mar 2004 23:28:02 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

address@hidden (Paul Jarc) writes:

> Marius Vollmer <address@hidden> wrote:
>> But car/cdr are not a good way to work with general sequences.  Think
>> of vectors.
> car/cdr certainly can be made to work with vectors.  [...]

Yes, but would that be a _good_ way to work with them?  It would be,
in my view, only a kluge to make routines work with vectors that were
originally written for lists.  Such automatic code reuse or rather
code-napping doesn't sound like a good idea to me.

>> Somehthing like the 'sequence' concept of Common Lisp is a better
>> approach, I'd say.
> AFAICT, that would involve a whole new set of procedures to work with
> this new data type.  I'm suggesting modifying the existing procedures
> so that most existing code would automatically be able to take
> advantage of the new flexibility, with no further changes needed.

What would the advantage be?  Some of the existing list routines will
sort of work with vectors, but vectors are not lists, and the results
will be strange at best.  Lists in Scheme and Lisp are not merely
sequences, they are able to form general trees with all kinds of
intentional structure sharing.  Vectors are not at all like this.

What would is (cons (car vec) (cdr vec))?  A pair with a vector as its
second argument?  A vector?

Some lists are uses as sequences and it would indeed make sense to
formalize this by introducing an abstract 'sequence' type for this,
I'd say.  Maybe by going over SRFI-1 and picking out the procedures
that treat lists as sequences.  Maybe such a thing already exists.

GPG: D5D4E405 - 2F9B BCCC 8527 692A 04E3  331E FAF8 226A D5D4 E405

reply via email to

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