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

[Epic] The Great Indexing Compromise #2117

Closed
rebolbot opened this issue Feb 27, 2014 · 3 comments
Closed

[Epic] The Great Indexing Compromise #2117

rebolbot opened this issue Feb 27, 2014 · 3 comments

Comments

@rebolbot
Copy link
Collaborator

Submitted by: abolka

Rebol 2, Rebol 3, and Red currently all use slightly differing indexing models -- the stuff that underlies how path-based indexing, pick, poke, index? work.

Under much sweat and tears, this issue was intensely and extensively debated on the REBOL4 AltME world during Nov 2012. Without trying to summarise or even repeat the argument here, none of the two prominent positions could reach convincing consensus. But behold: many participants sensed eventually, that a compromise was reached.

This is a meta-issue to summarise and track the steps toward that compromise.

The corner stones of this compromise:

  1. Non-contiguous ordinal indexing ("1-based") with zero hole for paths, pick, poke, index? ("like R2").
  2. Contiguous offset indexing ("0-based") with pickz, pokez, indexz? (to be newly introduced). Details in PICKZ and POKEZ functions for 0-based indexing. #613.
  3. "Backwards" ordinal accessors: first-back, second-back, third-back. Details in Ordinal functions in the other direction #1983.
  4. Errors upon falling into the zero hole: so pick [] 0 would cause an error (and not silently return NONE as in R2).

CC - Data [ Version: r3 master Type: Issue Platform: All Category: Unspecified Reproduce: Always Fixed-in:none ]

@rebolbot
Copy link
Collaborator Author

Submitted by: BrianH

Note: The bounds checking changes introduced in Rebol 3 (first "" == none rather than triggering an error) are pointedly not part of this compromise. If we need to tweak those, that's a separate debate that hasn't happened yet (though Ladislav and I discussed some ideas a while ago, to no conclusion yet). This is just about the overall indexing model(s).

@ladislav
Copy link
Contributor

  • I think that the current state already is a "compromise" in the sense that everybody tolerates it to some extent, although there are simple cases that are obvious bugs
  • I think that we need a deeper analysis to make qualified decisions

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
@hostilefork
Copy link
Member

hostilefork commented Jun 23, 2018

Implemented in Ren-C, without significant concern over compatibility. The body of affected code that is in use which can't be patched is too small to worry over, and the goal of compatibility is generally to match Rebol2 and Red semantics vs. the (non-existent) R3-Alpha codebases that don't already use Ren-C in 2018.

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

3 participants