Email list hosting service & mailing list manager


string comparison predicates return non-boolean values Matthias Radestock 10 Jan 2006 17:12 UTC

Lindsay Smith reported the following bug in SISC, which turns out to be
present in the srfi-13 reference implementation:

#;> (string> "bar" "foo")
#f ;;good
#;> (string> "foo" "bar")
0  ;;bad

The srfi-13 spec clearly states that the return value should be a
boolean. Further investigation shows that all string comparison
predicates suffer from this problem, returning a numeric value when they
should be returning #t.

The cause is found in the way %string-compare and %string-compare-ci are
called by the predicates. The procedures take three continuations as
arguments - for the <,=,> cases. These continuations are invoked with an
index.  For string< the < continuation is 'values' and the other two are
(lambda (i) #f). So if the first k is invoked we end up with the index
as the result. Similarly for the other string comparison predicates.

The fix is to replace 'values' with (lambda (i) #t).

Matthias