• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Oldes
15-Nov-2012
[3630]
Anyway.. reading this discussion, I'm feeling like deja vu... I would 
stay with REBOL way of indexing. Although I don't have any problem 
to switch into 0-based indexing in other languages. The problem is, 
that the other languages don't have functions like next, back, tail.. 
which enable series traversing, do they?
Andreas
15-Nov-2012
[3631]
Keeping negative indices with R2's weird behaviour only for the convenience 
of being able to write "foo/-1" is not worth it, in my eyes.
Ladislav
15-Nov-2012
[3632]
Oldes: C does have pointer arithmetic, which is, in many ways, isomorphic 
to SKIP
Andreas
15-Nov-2012
[3633x2]
Keeping R3's behaviour is certainly a possibility.
Oldes: next/back/tail/etc would work just as fine with indices-as-offsets 
("0-based").
DocKimbel
15-Nov-2012
[3635]
Andreas: what do you propose to replace "foo/-1" if negative indexes 
are disallowed? "first skip foo -1"?
Maxim
15-Nov-2012
[3636]
anyhow I always considered negative indices to be a bad idea.  I 
find SKIP and BACK convey much better meaning, because they are inherently 
directional (vectorial) by nature.  


IMHO  negative indices should have been implemented like in python, 
where they count from the tail, rather than "curren" position.   
they are MUCH more useful, they would be used daily by me (and most 
rebolers) in such a case.
Oldes
15-Nov-2012
[3637]
I was thinking about high level languages. For pointers is 0-based 
indexing logical.
Maxim
15-Nov-2012
[3638]
foo/-1    ==    skip tail foo -1
Andreas
15-Nov-2012
[3639x3]
Maxim, that does not correspond to current R2/R3 behaviour. We are 
talking about indexing "backwards" from the current position.
(But I also prefer Python's behaviour :)
DocKimbel: yes, either `first skip foo -1`, or `pickz foo -1`, or 
`foo/-1st`.
Oldes
15-Nov-2012
[3642]
I somehow incline to R2's behaviour just with error instead of none 
for 0's index
Andreas
15-Nov-2012
[3643]
And no error for out-of-bounds indices?
Oldes
15-Nov-2012
[3644]
To me, the description here http://www.rebol.com/docs/core23/rebolcore-6.html#section-1.1
is logical, but I'm not a scientist.
Ladislav
15-Nov-2012
[3645]
Andreas: what do you propose to replace "foo/-1" if negative indexes 
are disallowed? "first skip foo -1"? - In 1-based indexing without 
negative values it should be PICK-BACK FOO 2, in fact, which is awful
Maxim
15-Nov-2012
[3646]
it can still change for R3... very little code uses negative indices. 
 


 its already incompatible with R2, so we might be better off finding 
 the proper incompatibility than trying to "wing it" in the name of 
 continuity.   same for Red, it is free to be better than its pre-decessors. 
    


python's  negative indices where a revelation when I used python. 
 It was one of the very few redeeming features I found it had.
Oldes
15-Nov-2012
[3647]
I use pick ONLY in case where I don't want to get error if I'm out 
of bounds
Andreas
15-Nov-2012
[3648]
Ladislav: I would still keep offset-based SKIP.
Oldes
15-Nov-2012
[3649]
hm.. now I see, that even select and path notation is not returning 
error.. so I don't know where I came to this.
Ladislav
15-Nov-2012
[3650]
Yes, I just explained what should be used instead of PICK FOO -1
Andreas
15-Nov-2012
[3651]
I'd rather add an offset-based PICKZ than a PICK-BACK :)
Ladislav
15-Nov-2012
[3652x2]
(when being consistent, that is)
Andreas, I understand, I was just showing the consistent usage of 
1-based indexing without zero
Andreas
15-Nov-2012
[3654]
Could also be `pick skip foo -1 1`, but that is not less awful.
Ladislav
15-Nov-2012
[3655]
Could also be `pick skip foo -1 1`

 - yes, but that is not the direct equivalent of (inconsistent) PICK 
 FOO -1
Andreas
15-Nov-2012
[3656x3]
Yes.
Of PICK-FORWARD 1 returns the current value, PICK-BACKWARD 1 should 
of course also return the current value.
If*
Ladislav
15-Nov-2012
[3659]
Exactly what I was trying to emphasize
Oldes
15-Nov-2012
[3660]
From R3-alpha world:

Carl:	It is zero based for math computation reasons. If you think 
that is wrong, we should discuss it and correct it soon.	11-Oct-2007 
6:03:15 PM

Carl:	Rest of REBOL is one based for this reason: first = pick series 
1	11-Oct-2007 6:03:33 PM

Carl:	The solution we discussed, but have not yet implemented (but 
it is easy to do) is to add a PICKZ (or PICK0) function.	11-Oct-2007 
6:05:41 PM

BrianH	: Those math computation reasons are why I prefer zero based. 
I tend to use SKIP instead of AT for the same reason.	11-Oct-2007 
6:06:09 PM

BrianH	: Please add PICKZ and POKEZ - I liked them in rebcode.	11-Oct-2007 
6:06:46 PM
Ladislav
15-Nov-2012
[3661]
If PICK-FORWARD 1 returns the current value, PICK-BACKWARD 1 should 
of course also return the current value.
 - which, actually, leads to "overlaying", not to "gap-making".
Oldes
15-Nov-2012
[3662]
(Carl in the post above was answering why vector in the initial R3 
version was 0-based. He changed it afterwords to 1-based but never 
created promised *z functions.)
Ladislav
15-Nov-2012
[3663x2]
Frankly, I am not overly enthusiastic about the PICKZ name, any other 
reasonable idea?
(I mean of the name for such function)
Oldes
15-Nov-2012
[3665]
I don't think there will be better. And it was used in rebcode.
Ladislav
15-Nov-2012
[3666]
In the synonyms for PICK I found ELECT, what about that?
Arnold
15-Nov-2012
[3667]
REPICK REVPICK PREVGET NEGINDX PREPICK PICK-PREV NINDEX 
ELECT? -> NEGLECT ;)
Ladislav
15-Nov-2012
[3668x3]
My idea:

One-based        Zero-based
AT                        SKIP
PICK                    ELECT
INDEX?               BASIS?
FIRST                  ELECT0
SECOND            ELECT1
THIRD                 ELECT2
FOURTH             ELECT3
FIFTH                   ELECT4
SIXTH                   ELECT5
SEVENTH            ELECT6
EIGHTH                ELECT7
NINTH                   ELECT8
TENTH                  ELECT9
LAST                      LAST
HEAD?                  HEAD?
TAIL?                     TAIL?
LAST?                    LAST?
Having that, I would just be able to foget about one-based indexing 
happily ever after...
maybe adding ELECT-1 that may be needed often as well.
Oldes
15-Nov-2012
[3671]
I would hardly ever use elect* actions as I almost never use first, 
second... actions. Actually my english is so bad that I see elect 
for the fist time:)
Ladislav
15-Nov-2012
[3672x3]
I am in favour of ELECT also because it looks "higher level" than 
PICK. PICK seems to look quite "Low level", while in REBOL it isn't 
as "Low level" as it may suggest at the first sight.
(I mean to the users coming from other languages)
as far as I am concerned I would not need ELECT3 and above, but up 
to ELECT2 they look nice to have.
Oldes
15-Nov-2012
[3675]
Ah.. elect like election... that makes sense to have it zero based 
as usually it's hard to elect someone from possible given choices... 
sorry off topic.
Ladislav
15-Nov-2012
[3676x2]
LOL
aha, still not done, I would need to find a name for the zero-based 
counterpart of POKE...
Arnold
15-Nov-2012
[3678x2]
elect is very like select
I had this idea when under the shower, so it is still a bit wet: 
DOWNPICK