On Wednesday 22 October 2008 11:06:48 Andre van Tonder wrote: > I mean the following. R6RS already has a list-sort and vector-sort that > allows empty and singleton lists and vectors. > You would prefer to have > > (sorted? (list-sort < '(1))) ==> #f > > In other words, according to your preferred definition of sorted?, the > result of sorting a list is not necessarily a sorted list. That would be > rather counterintuitive to most people.
Ah. Thanks for the clarification. List-sort and vector-sort are to perform a stable sort and are required to return their list or vector arguments. They are NOT required to return a sorted result or to signal an error if their arguments cannot be sorted [e.g. when their arguments cannot be ordered]. I agree that it may not be intuitive. You can say that incomparable things can't be ordered so they can't be sorted. Note that the comparison operator is not necessarily applied. [I won't say which implementation I typed this into]: (list-sort char<? '(3)) ==> '(3) Am I to infer that '(3) is sorted according to char<? and I can cons new characters in a way to keep this as an invariant? Yes, this could be fixed for the singleton list/vector case by requiring both a type predicate as well as a comparison predicate or by requiring every sort routine to call comparson predicates in at least the singleton cases and further to require type checking by user predicates on these cases, but this also requires explaining to users why a _binary_ relation predicate needs to handle the case where it gets only one -- not two -- arguments and to do a type-check even though it can't test for a relation. Taking a quick look at the code for SRFI-32, I don't immediately see this as a win. Perhaps some one can point this out to me. I am afraid that non-intuitive is a description of the situation. -KenD _______________________________________________ r6rs-discuss mailing list [email protected] http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss
