World: r4wp
[#Red] Red language group
older newer | first last |
DocKimbel 17-Nov-2012 [3940] | probe s3/-2 - this is shorthand for back back s3 or pick s3 -2 (the negative number simply means move back twice) => 'd That is the interpretation you can make in R2, but it is no more valid in R3. |
kensingleton 17-Nov-2012 [3941] | I honestly think there is so much confusion over this because we are trying to merge together two different "concepts". Concept 1 is a series which is traversed as in Rebol 2 and whre s/-2 is shorthand for back back s. Concept 2 is a 0 based sequence which is traversed via index manipulation. The concepts need to be kept seperate even if they are applied to the same set of contiguous boxes. The only way to do this as far as i can see is to develop a set of index manipulation functions in addition to the existing series traversal functions. The concepts can then be easily taught to newbies and gurus can mix and match to their hearts content. |
Andreas 17-Nov-2012 [3942] | If anything, s/-2 is a shorthand for `FIRST back back s`. |
kensingleton 17-Nov-2012 [3943] | Andreas - yes - agreed |
Andreas 17-Nov-2012 [3944] | Whereas s/2 could be conceived as shorthand for `first next s`. And there you already get a glimpse at the problem: - s/2 is first next s, s/-2 is first back back -- why is there 1 next but 2 backs? - what is s/0? |
kensingleton 17-Nov-2012 [3945] | There is no 0 by convention - that is what defines the "concept" of series traversal. Arrays are traversed by index manipulation whether 0 based or not.. |
DocKimbel 17-Nov-2012 [3946] | Concept 2 is a 0 based sequence which is traversed via index manipulation. That interpretation doesn't match `FIRST s` and `PICK s 1`... |
kensingleton 17-Nov-2012 [3947] | Yes but Frst s and Pick s 1 are series functions - not index manipulation functions - different concepts - first s in index system would be s[i] |
Andreas 17-Nov-2012 [3948x2] | the 1 in `pick s 1` sure awfully looks like an index to me :) |
But, agreed, Ken. That's basically the same distinction I keep trying to make, by separating ordinal access from other possible accesses. | |
kensingleton 17-Nov-2012 [3950x5] | The 1 in Pick s 1 is not an index it is an offset from s |
if s is at box 4 in the original series then pick s 1 returns the contents of box 4 not box 1 | |
In an index system if you want box 4 you say s[4] - or if your current index is at 1 and you want box 4 you say s[i + 3] | |
Andreas - the problem I have with ordinals is how do you do mathematics on them eg. 3 + -3rd ? Index manipulation uses ingteger! and so is mathematically modifiable | |
Anyway - good luck Doc on sorting this one out - and thanks again for doing Red it is very exciting | |
Kaj 17-Nov-2012 [3955] | I like Andreas' proposal |
Andreas 17-Nov-2012 [3956x5] | Ken, re maths for ordinals: just a matter of how you want to define it. |
-3rd + 3 == 1st | |
1st -1 = -1st, -1st + 1 = 1st, 1st + 0 = 1st | |
The more interesting question is how ordinals map to integers :) That basically requires a decision of how you want to do indexing with integers, then it's easy as well. | |
One possibility. Another would be to have ordinals purely as syntactic convenience, and not allow arithmetics with them. | |
kensingleton 17-Nov-2012 [3961x2] | Ok - thanks for the clarification Andreas - that makes sense now. I think maths usage would be essential for use cases such as the one Brian put forward - he mentioned at least addition and modulo. |
Anyway - I have shared what I felt I needed to say. I will now leave it to the guru's to decide the way forward on this matter. My knowlege of Rebol is not sufficient to push any particular solution. | |
Ladislav 17-Nov-2012 [3963x4] | It's just a dialect for going in the opposite direction - it is not, in fact. (PICK SERIES INDEX) is just an evaluation of a function, not a "dialect" |
I don't buy the no right" argument. Romans had subtraction without 0. It was a bad idea, but it was possible." Yes, but -1 is not "subtraction", it is a value. | |
Now, try to come up with a way to explain to newbies that this phantom hole in a series makes sense, or is a good idea. - yes, a good illustration from a beginner/documentation/education POV. Also, what is exactly as bad even for experienced users is that it disrespects arithmetic making simple index arithmetic (ADD INDEX OFFSET) not usable. | |
...it means that 0 doesn't exist, like we're programming in Roman. - again, a cute formulation. I bet that there is no "programming in Roman", the word "algorithm" is from the world where 0 does exist. | |
DocKimbel 17-Nov-2012 [3967] | Kensingleton: thank you very much for your inputs. Having different point of view is helpful. |
Kaj 17-Nov-2012 [3968x3] | It's just a dialect for going in the opposite direction" - it is not, in fact. (PICK SERIES INDEX) is just an evaluation of a function, not a "dialect"" |
False. PICK SERIES INDEX is usually evaluated as DO dialect. It could also be evaluated as any other dialect | |
SERIES/-1 is not even function evalutation in the DO dialect, it's path evaluation | |
DocKimbel 17-Nov-2012 [3971] | Also, what is exactly as bad even for experienced users is that it disrespects arithmetic making simple index arithmetic (ADD INDEX OFFSET) not usable. I guess you're not talking about R2, which index arithmetic has proven to be very usable in last twelve years (at least) through countless *working* user apps. |
Ladislav 17-Nov-2012 [3972] | My Understanding of Series: A contiguous collection of boxes sequentially numbered in ascending order starting at 1. - this is correct only for series I would call "Head Series", i.e. such series that are their own heads. |
BrianH 17-Nov-2012 [3973x2] | Agreed, "not usable" is a little harse. Bad and awkward, but once you work around that it is usable. |
harse -> harsh | |
Ladislav 17-Nov-2012 [3975] | I guess you're not talking about R2, which index arithmetic has proven to be very usable in last twelve years (at least) through countless *working* user apps. - "working" are only the ones limiting the index arihmetic to some special cases. Those not limiting themselves to such cases are not working. |
Andreas 17-Nov-2012 [3976x2] | You actually have that you have to work around it, otherwise R2 will bite you hard (and silently). |
... have to know* that you have to work around it ... | |
Ladislav 17-Nov-2012 [3978x12] | You actually have that you have to work around it, otherwise R2 will bite you hard (and silently). - yes, "you have to work around it" is (for me) a different formulation equivalent to "not working" |
I am able to do any work-arounds necessary at any time. However, I prefer to use a working solution. | |
Knowing Carl's preferences, I did not insist on switching to 0-based indexing. However, for the sake of arithmetic, I at least convinced him to switch to "continuous indexing". | |
Here is a task I consider relevant: 1) define a function obtaining a series S and an index I and yielding an index J such that PICK S I would be equivalent to PICK HEAD S J 1a) do the task in R2 1b) do the task in R3 1c) do the task in R4 with zero-based indexing | |
This is my solution of 1c): head-index?: func [s [series!] i [integer!]] [i + index? s] | |
(that is what I call "working index arithmetic") | |
This is my solution of 1b): head-index?: func [s [series!] i [integer!]] [i - 1 + index? s] | |
(again, a case of "working index arithmetic") | |
(although a bit more complicated than the 1c case) | |
1a) is a task for people stating that "zero does not exist" | |
...and also for people stating that "index arithmetic *is* working in R2" | |
Note that the difference between 1c) and 1b) seems to demonstrate why 0-based indexing may be found more convenient than 1-based indexing | |
older newer | first last |