[Top][All Lists]

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

[Chicken-hackers] substring=?

From: Elf
Subject: [Chicken-hackers] substring=?
Date: Fri, 26 Aug 2016 02:46:38 -0700 (PDT)
User-agent: Alpine 2.20 (LRH 67 2015-01-07)

Hello all,

Sjamaan and Mario on the channel brought up an interesting issue with
substring=?. The current semantics check only to the length of the
shorter string, so:

(and (substring=? "foo" "foobar") (substring=? "foobar" "foo")) => #t

I submit that this behaviour is conceptually broken.

substring is an instance of a subset operation, and

(and (subset? a b) (subset? b a)) => #t

always implies that a = b.

I think the correct behaviour would be adding a check to the beginning
of the substring=? procedure, such that

(if (> (length a) (length b)) #f ...)

That said, I can understand the point of a string comparator that only
tests up to the length of the shortest argument, but I submit that it
shouldn't be named substring, which has different normal semantics. :)

Thoughts, ideas, changes, flames?


reply via email to

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