Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AT has off-by-one error for indexes < 1. #609

Closed
rebolbot opened this issue Feb 9, 2009 · 2 comments
Closed

AT has off-by-one error for indexes < 1. #609

rebolbot opened this issue Feb 9, 2009 · 2 comments

Comments

@rebolbot
Copy link
Collaborator

rebolbot commented Feb 9, 2009

Submitted by: BrianH

AT series 0 is the same as AT series 1. For 1-based indexing, the 0 index should be one back from the current position, the -1 index two back, and so on.

This bug prevents calculation of the index argument, which is necessary for simulating 0-based indexing amongst other things. Both blocks and strings are affected.

Note: R2 also has this bug.

CC – Data [ Version: alpha 33 Type: Bug Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ]

@rebolbot
Copy link
Collaborator Author

rebolbot commented Mar 5, 2014

Submitted by: BrianH

According to the index compromise in #2117 this is not a bug.

@rebolbot
Copy link
Collaborator Author

rebolbot commented Mar 6, 2014

Submitted by: abolka

According to #2117 a part of this ticket is still important: AT series 0 should cause an error. But it's best to track that in a separate ticket.

Oldes added a commit to Oldes/Rebol3 that referenced this issue Jun 13, 2018
In Rebol2, picking value with index 0 was always returning null. In R3-alpha it was changed that zero index was working like index -1... more at this blog http://www.rebol.net/cgi-bin/r3blog.r?view=0173

I decided to revert this change and let it working as before (and so be compatible with Red too)

So now it works for example like:

>> pick tail "123" -1
== #"3"
>> pick tail "123" 0
== none

and it is also consistent with AT positioning:

>> at tail "123" -1
== "3"

Related issues:
metaeducation/rebol-issues#608
metaeducation/rebol-issues#609
metaeducation/rebol-issues#748
metaeducation/rebol-issues#857
metaeducation/rebol-issues#2117

and also:
metaeducation/rebol-issues#613
hostilefork added a commit to metaeducation/ren-c that referenced this issue Jun 14, 2018
Consensus in general was that the negative indexing behavior of
R3-Alpha was not pleasing.  This restores the historical behavior.
Also makes it so that picking with DECIMAL! will round the decimal
down and use the INTEGER! value, vs. SELECT-ing the DECIMAL.

Commit initiated by Oldes in:

Oldes#5

His comments there:

"In Rebol2, picking value with index 0 was always returning null. In
R3-Alpha it was changed that zero index was working like index -1...
more at this blog http://www.rebol.net/cgi-bin/r3blog.r?view=0173"

"I decided to revert this change and let it working as before (and so
be compatible with Red too)"

"So now it works for example like:"

    >> pick tail "123" -1
    == #"3"
    >> pick tail "123" 0
    == none

"and it is also consistent with AT positioning:"

   >> at tail "123" -1
   == "3"

"Related issues:"

metaeducation/rebol-issues#608
metaeducation/rebol-issues#609
metaeducation/rebol-issues#748
metaeducation/rebol-issues#857
metaeducation/rebol-issues#2117

"and also:"

metaeducation/rebol-issues#613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant