[Standards] Off-by-one error in XEP-372 "References"

Andrew Nenakhov andrew.nenakhov at redsolution.com
Fri Dec 4 23:34:58 UTC 2020


There is actually a fourth sensible option:

4. Start = first character (inclusive) and length = length of a substring.

Just saying. It could be easier to implement for some people.

пт, 4 дек. 2020 г. в 19:21, Tedd Sterr <teddsterr at outlook.com>:
>
> "How to specify character ranges" is a problem that keeps appearing - can we resolve this once and for all, and then ensure we're consistent with that in all XEPs?
>
> There are only three sensible options:
>
> 1. Start = first character (inclusive), end = last character (exclusive);
> 2. Start = first character (inclusive), end = last character (inclusive);
> 3. Start = Boundary before first character, end = boundary after last character.
>
> Option 1 is what I presume most are familiar with as that's how indexing works in many programming languages, and option 2 makes some sense as you're pointing to the first and last characters to be included. The problem with the first two options is that it leads to this inclusive/exclusive confusion where the text seems to say one thing and the example says another.
>
> Option 3 sidesteps that issue by indexing the positions between characters, rather than the characters themselves - so a character is either before or after a boundary, and is explicitly included or excluded from a range. Numerically, this is actually equivalent to option 1, but by describing it in this way, the confusion never arises.
>
> _______________________________________________
> Standards mailing list
> Info: https://mail.jabber.org/mailman/listinfo/standards
> Unsubscribe: Standards-unsubscribe at xmpp.org
> _______________________________________________



-- 
Andrew Nenakhov
CEO, redsolution, OÜ
https://redsolution.com


More information about the Standards mailing list