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

PICKZ and POKEZ functions for 0-based indexing. #613

Closed
Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Closed

PICKZ and POKEZ functions for 0-based indexing. #613

Siskin-Bot opened this issue Feb 15, 2020 · 0 comments
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.wish

Comments

@Siskin-Bot
Copy link
Collaborator

Siskin-Bot commented Feb 15, 2020

Submitted by: BrianH

PICKZ and POKEZ would be (preferably native) wrappers around the PICK and POKE actions that would add 1 to their index argument before passing it along. This would provide 0-based indexing for all series.

These functions would be limited to datatypes that take the PICK and POKE actions with numeric indexes only. The map! type can take numeric keys, but support for map! in PICKZ and POKEZ seems silly.

The names come from the Rebcode operations.


Imported from: CureCode [ Version: alpha 33 Type: Wish Platform: All Category: n/a Reproduce: Always Fixed-in:none ]
Imported from: metaeducation#613

Comments:

Rebolbot commented on Feb 11, 2009:

Submitted by: BrianH

If these are native it could let us make vector! 1-based without much overhead for 0-based use.


Rebolbot commented on Mar 4, 2013:

Submitted by: abolka

Strong +1 for adding these.

Please also add a "0-based" INDEX? dual: I'd suggest INDEXZ?.


Rebolbot mentioned this issue on Jan 12, 2016:
Make VECTOR! of same index-base as other series
Make SERIES/#INDEX path forms act as PICKZ and POKEZ on the value in INDEX


Rebolbot mentioned this issue on Jan 22, 2016:
[Epic] The Great Indexing Compromise


Rebolbot added the Type.wish on Jan 12, 2016


Ladislav commented on Feb 21, 2016:

"PICKZ and POKEZ would be (preferably native) wrappers around the PICK and POKE actions that would add 1 to their index argument before passing it along. This would provide 0-based indexing for all series." - this looks simple, but it is rather problematic, in fact:

PICK and POKE accept a nonnative (1-based) index value transforming it to its native (0-based index value for the native C code) counterpart. This transformation is not free, my tests revealed that the overflow that can occur during the transformation due to limited range, and some other issues that can occur due to non-arithmetic indexing are not handled properly. Adding another index transformation on top of the mess is yet another source of possible bugs.


Oldes added a commit to Oldes/Rebol3 that referenced this issue on Jun 13, 2018:
FEAT/FIX: Picking the right PICK


Oldes mentioned this pullrequest on Jun 13, 2018:
FEAT/FIX: Picking the right PICK


Hostilefork added a commit to metaeducation/ren-c that referenced this issue on Jun 14, 2018:
Restore Rebol2-era PICKing/PATHing of negative/zero indices


Hostilefork mentioned this pullrequest on Jun 14, 2018:
Restore Rebol2-era PICKing/PATHing of negative/zero indices


@Oldes Oldes added Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written labels Oct 6, 2021
Oldes added a commit to Oldes/Rebol3 that referenced this issue Oct 6, 2021
Oldes added a commit to Oldes/Rebol3 that referenced this issue Oct 6, 2021
CHANGE: `at` action on image with pair position was 0-based, now is 1-based

related to: Oldes/Rebol-issues#613
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Oldes.resolved Bugs/wishes with Oldes' fixes/features Test.written Type.wish
Projects
None yet
Development

No branches or pull requests

2 participants