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

*To*: Sebastian Egner <sebastian.egner@xxxxxxxxxxx>*Subject*: Re: vector compare*From*: Per Bothner <per@xxxxxxxxxxx>*Date*: Thu, 09 Jun 2005 00:59:11 -0700*Cc*: srfi-67@xxxxxxxxxxxxxxxxx*Delivered-to*: srfi-67@xxxxxxxxxxxxxxxxx*In-reply-to*: <OF7B1F9CDE.F4ED119E-ONC125701B.0027F89A-C125701B.002840B7@xxxxxxxxxxx>*References*: <OF7B1F9CDE.F4ED119E-ONC125701B.0027F89A-C125701B.002840B7@xxxxxxxxxxx>*User-agent*: Mozilla Thunderbird 1.0.2-1.3.2 (X11/20050324)

Sebastian Egner wrote:

> The default compare for vectors is unusual, and more critically it is > incompatible with the default compare for lists and strings. > The latter are both lexicographic compare. Correct. In this SRFI, vectors are compared first by length and then lexicographically by default. > I couldn't find a rationale for this difference. The paragraph "What is the 'natural order' of lists and vectors?'

http://srfi.schemers.org/srfi-67/srfi-67.html#node_toc_node_sec_Temp_20

I don't get it. How is that a rationale? Do you have any examples or use cases or algorithms that are simpler when using this "natural order"? What prior art is there for using this order?

If I understand correctly, your argument is that LIST and VECTOR should both be interpreted as mere implementations of some abstract SEQUENCE data type,

I'm saying that some Scheme implementations (at least Kawa) and at least one SRFI (44) does this. I'm also pointing out that Common Lisp does this. I.e. this is not a far-fetched concept.

and that the ordering should be defined for SEQUENCE, only.

Not quite. It is true that if an ordering is defined for sequence, then it would be bad to define inconsistent orderings for different sub-types of sequence. I'm making a weaker claim: if you define an operation F on type A and on type B that are both sub-types of a common super-type S then good object-oriented design suggests you should define the operation F to have common properties (axioms) for both A and B. Even if you view vectors and lists as both sequences, it doesn't follow that on operation F must be defined in terms of sequences. However, it's usually a good idea. Moreover, some schemes provide "uniform vectors", and there are SRFIs that define them. What is the natural order for a uniform vector? By your argument, and I think "common sense" (admittedly unreliable) it should be the same order as for normal vectors. Certainly if you believe uniform vectors "inherit" from an "abstract vector" type. Now consider strings. Is a string a vector? If you have uniform vectors, then it seems very strange to not view a string as a uniform vector. It follows that the ordering for strings should be the same as for uniform vectors. Strings use lexicographic order. Hence uniform vectors should use lexicographic order. Hence vectors should use lexicographic order. -- --Per Bothner per@xxxxxxxxxxx http://per.bothner.com/

**Follow-Ups**:**Re: vector compare***From:*Jens Axel Søgaard

**References**:**Re: vector compare***From:*Sebastian Egner

- Prev by Date:
**Re: vector compare** - Next by Date:
**Re: Optional arguments at the beginning** - Previous by thread:
**Re: vector compare** - Next by thread:
**Re: vector compare** - Index(es):