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

2020-12-07 Thread JC Brand

Thanks everyone for the feedback.

I've made a PR here: https://github.com/xsf/xeps/pull/1018

The proposed change is the have the begin index inclusive and the end 
index exclusive, similarly to how Converse and Xabber do it currently.


This is known as the Dijkstra convention, and I presume it's based on 
his proposal here: 
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html


This matches how subsequence indexing is done in many programming 
languages and has the added advantages that 'end' minus 'begin' equals 
the length of the substring and if two referenced substrings are 
adjacent, then the 'end' of the first matches the 'begin' of the second.


This also appears to be the convention most people in the thread 
appeared to agree with.


- JC



On 04.12.20 13:31, JC Brand wrote:

Hey folks

In XEP-0372 in section 3.1, there is the following text:

An end attribute is similarly  used for the index of the last 
character of the reference


However, in the example in 3.2, the "end" attribute is set to 78, 
which is the index of the space after the nickname "Juliet".


The example appears to contradict the text. I'd like to fix this, but 
I'm not sure what the original author's intention was. I'm assuming 
the text is correct and the example is wrong.


AFAIK only Converse.js and maybe Movim support this incomplete XEP.

If anyone else is using it, I'd appreciate it if you could let me know 
which offset you're using. Converse is currently following the example 
in the XEP, i.e. i+1.


Thanks
JC


___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-05 Thread Sam Whited
Oh yes, of course. I see what you're saying now.

—Sam

On Sat, Dec 5, 2020, at 01:24, Andrew Nenakhov wrote:
> сб, 5 дек. 2020 г. в 05:12, Sam Whited :
> >
> >
> >
> > On Fri, Dec 4, 2020, at 23:34, Andrew Nenakhov wrote:
> > > 4. Start = first character (inclusive) and length = length of a
> > >substring.
> >
> > This is the same as "1. Start = first character (inclusive), end =
> > last character (exclusive);"
>
> No.
>
> string: abcdefgh
>
> 4. start = 3, length = 2. Result: de
>
> With 1, it would be:
>
> 1. start = 3, end = 5. Result: de
>
>
>
>
> --
> Andrew Nenakhov CEO, redsolution, OÜ https://redsolution.com
> ___
> Standards mailing list Info:
> https://mail.jabber.org/mailman/listinfo/standards Unsubscribe: Standards-
> unsubscr...@xmpp.org
> ___
>

-- 
Sam Whited
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Andrew Nenakhov
сб, 5 дек. 2020 г. в 05:12, Sam Whited :
>
>
>
> On Fri, Dec 4, 2020, at 23:34, Andrew Nenakhov wrote:
> > 4. Start = first character (inclusive) and length = length of a
> >substring.
>
> This is the same as "1. Start = first character (inclusive), end = last
> character (exclusive);"

No.

string: abcdefgh

4. start = 3, length = 2. Result: de

With 1, it would be:

1. start = 3, end = 5. Result: de




-- 
Andrew Nenakhov
CEO, redsolution, OÜ
https://redsolution.com
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Sam Whited


On Fri, Dec 4, 2020, at 23:34, Andrew Nenakhov wrote:
> 4. Start = first character (inclusive) and length = length of a
>substring.

This is the same as "1. Start = first character (inclusive), end = last
character (exclusive);"

—Sam
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Andrew Nenakhov
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 :
>
> "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-unsubscr...@xmpp.org
> ___



-- 
Andrew Nenakhov
CEO, redsolution, OÜ
https://redsolution.com
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Tedd Sterr
"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-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Florian Schmaus

On 12/4/20 1:31 PM, JC Brand wrote:

Hey folks

In XEP-0372 in section 3.1, there is the following text:

An end attribute is similarly  used for the index of the last 
character of the reference


However, in the example in 3.2, the "end" attribute is set to 78, which 
is the index of the space after the nickname "Juliet".


Yep, that should be 77 and the XEP should explicitly state that the end 
index is exclusive (while the start index is inclusive). Together with 
the numbering being zero-indexed, this would be similar to the behavior 
of APIs like Android's android.text.Spannable.


While at it, the textual  content of the examples in the XEP 
should be way shorter. And it should be explicitly explained which part 
of the text is referenced, e.g.:


Text is spantastic!

begin=8
  end=12

- Florian






OpenPGP_signature
Description: OpenPGP digital signature
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Andrew Nenakhov
Well most participants of the previous discussion on this list were
strongly against i+0 approach which we did at first, so since we
didn't really hold any strong position on this, we just switched to
i+1. The one advantage of this approach is that you can derive the
length of the string directly by subtracting begin value from end
value (big help if you have difficulties with +1 operation), and it's
somewhat more common with array slicing in various programming
languages.

But yes, the original point still stands, the text of the XEP clearly
contradicts the examples.

пт, 4 дек. 2020 г. в 18:24, Severino Ferrer de la Peñita :
>
> Hi,
>
> I already discussed this with the author, you can read more about it on the 
> following logs: 
> https://logs.xmpp.org/jdev/2020-10-06?p=h#2020-10-06-f8688aaa95f97e76
>
> I honestly don't believe `i+1` is correct.
> Could you please share some of that feedback, Andrew?
>
>
> Kind regards,
>
> Seve
>  https://delape.net
>  https://github.com/SeveFP
>
>
> > On 04/12/2020 13:40 Andrew Nenakhov  wrote:
> >
> >
> > We're currently use it in all our clients, extensively. We finally
> > settled on +1 offset because of feedback. That said, we use our own
> > namespace because we can and because XSF moves XMPP in the wrong
> > direction. :-D
> >
> > пт, 4 дек. 2020 г. в 17:33, JC Brand :
> > >
> > > Hey folks
> > >
> > > In XEP-0372 in section 3.1, there is the following text:
> > >
> > > > An end attribute is similarly  used for the index of the last character 
> > > > of the reference
> > >
> > > However, in the example in 3.2, the "end" attribute is set to 78, which
> > > is the index of the space after the nickname "Juliet".
> > >
> > > The example appears to contradict the text. I'd like to fix this, but
> > > I'm not sure what the original author's intention was. I'm assuming the
> > > text is correct and the example is wrong.
> > >
> > > AFAIK only Converse.js and maybe Movim support this incomplete XEP.
> > >
> > > If anyone else is using it, I'd appreciate it if you could let me know
> > > which offset you're using. Converse is currently following the example
> > > in the XEP, i.e. i+1.
> > >
> > > Thanks
> > > JC
> > >
> > >
> > > ___
> > > Standards mailing list
> > > Info: https://mail.jabber.org/mailman/listinfo/standards
> > > Unsubscribe: standards-unsubscr...@xmpp.org
> > > ___
> >
> >
> >
> > --
> > Andrew Nenakhov
> > CEO, redsolution, OÜ
> > https://redsolution.com
> > ___
> > Standards mailing list
> > Info: https://mail.jabber.org/mailman/listinfo/standards
> > Unsubscribe: standards-unsubscr...@xmpp.org
> > ___
> ___
> Standards mailing list
> Info: https://mail.jabber.org/mailman/listinfo/standards
> Unsubscribe: standards-unsubscr...@xmpp.org
> ___



-- 
Andrew Nenakhov
CEO, redsolution, OÜ
https://redsolution.com
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Severino Ferrer de la Peñita
Hi,

I already discussed this with the author, you can read more about it on the 
following logs: 
https://logs.xmpp.org/jdev/2020-10-06?p=h#2020-10-06-f8688aaa95f97e76

I honestly don't believe `i+1` is correct.
Could you please share some of that feedback, Andrew? 


Kind regards, 
 
Seve 
 https://delape.net 
 https://github.com/SeveFP 


> On 04/12/2020 13:40 Andrew Nenakhov  wrote:
> 
>  
> We're currently use it in all our clients, extensively. We finally
> settled on +1 offset because of feedback. That said, we use our own
> namespace because we can and because XSF moves XMPP in the wrong
> direction. :-D
> 
> пт, 4 дек. 2020 г. в 17:33, JC Brand :
> >
> > Hey folks
> >
> > In XEP-0372 in section 3.1, there is the following text:
> >
> > > An end attribute is similarly  used for the index of the last character 
> > > of the reference
> >
> > However, in the example in 3.2, the "end" attribute is set to 78, which
> > is the index of the space after the nickname "Juliet".
> >
> > The example appears to contradict the text. I'd like to fix this, but
> > I'm not sure what the original author's intention was. I'm assuming the
> > text is correct and the example is wrong.
> >
> > AFAIK only Converse.js and maybe Movim support this incomplete XEP.
> >
> > If anyone else is using it, I'd appreciate it if you could let me know
> > which offset you're using. Converse is currently following the example
> > in the XEP, i.e. i+1.
> >
> > Thanks
> > JC
> >
> >
> > ___
> > Standards mailing list
> > Info: https://mail.jabber.org/mailman/listinfo/standards
> > Unsubscribe: standards-unsubscr...@xmpp.org
> > ___
> 
> 
> 
> -- 
> Andrew Nenakhov
> CEO, redsolution, OÜ
> https://redsolution.com
> ___
> Standards mailing list
> Info: https://mail.jabber.org/mailman/listinfo/standards
> Unsubscribe: standards-unsubscr...@xmpp.org
> ___
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___


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

2020-12-04 Thread Andrew Nenakhov
We're currently use it in all our clients, extensively. We finally
settled on +1 offset because of feedback. That said, we use our own
namespace because we can and because XSF moves XMPP in the wrong
direction. :-D

пт, 4 дек. 2020 г. в 17:33, JC Brand :
>
> Hey folks
>
> In XEP-0372 in section 3.1, there is the following text:
>
> > An end attribute is similarly  used for the index of the last character of 
> > the reference
>
> However, in the example in 3.2, the "end" attribute is set to 78, which
> is the index of the space after the nickname "Juliet".
>
> The example appears to contradict the text. I'd like to fix this, but
> I'm not sure what the original author's intention was. I'm assuming the
> text is correct and the example is wrong.
>
> AFAIK only Converse.js and maybe Movim support this incomplete XEP.
>
> If anyone else is using it, I'd appreciate it if you could let me know
> which offset you're using. Converse is currently following the example
> in the XEP, i.e. i+1.
>
> Thanks
> JC
>
>
> ___
> Standards mailing list
> Info: https://mail.jabber.org/mailman/listinfo/standards
> Unsubscribe: standards-unsubscr...@xmpp.org
> ___



-- 
Andrew Nenakhov
CEO, redsolution, OÜ
https://redsolution.com
___
Standards mailing list
Info: https://mail.jabber.org/mailman/listinfo/standards
Unsubscribe: standards-unsubscr...@xmpp.org
___