Hi Henry, for the ANSI document on indexOfSubcollection:startingAt:, i think that 'aaaaa' indexOfSubcollection: '' startingAt: 1 must return 1, not 0. (and if the argument is empty the starting index must be returned) *Message: indexOfSubCollection: targetSequence startingAt: start Synopsis Answer the index of the first element of the receiver which is the start of a subsequence which matches targetSequence. Start searching at index start in the receiver. Answer 0 if no such subsequence is found. Definition: <sequenceReadableCollection> Each subsequence of the receiver starting at index start is checked for a match with targetSequence. To match, each element of a subsequence of the receiver must be equivalent to the corresponding element of targetSequence. Answer the index of the first element which begins a matching subsequence; no further subsequences are considered. Answer 0 if no such subsequence is found in the receiver, or if targetSequence is empty. The elements are traversed in the order specified by the #do: message for the receiver. * The problem here is probably that subsequence definition is missing in the standard. If an empty sequence is allowed as argument then I think that the index must be the result. ¿Anybody has a formal definition of subsequence? I don't know if the beginsWith: in SequenceableCollection must return true to #(1 2 3) beginsWith: #(), but for String I still think that must do. Obviously there's some part of the protocol that should remain consistent. I will try to analyze that in deeper detail later. Regards, Gabriel On Thu, Mar 4, 2010 at 11:27 AM, Henrik Johansen < henrik.s.johansen@veloxit.no> wrote:
Den 04.03.2010 14:40, skrev Julian Fitzell:
I'm not sure, but in ANSI, indexOfSubcollection:startingAt: is defined as returning 0 (no match) for an empty collection.
If a string can not contain the empty string, then how can (and does) it start/end with it? IMHO, to be consistent, the set of what I contain should be a strict superset of what I begin/end with.
In that regards, according to the ansi-standard, returning false is correct.
Cheers, Henry
_______________________________________________ Pharo-project mailing list Pharo-project@lists.gforge.inria.fr http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project