Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: R: Re: Correct Behaviour? Was False = 2 ????

From: ingo:2b1 at: 3-Jul-2001 13:21

Hi Mark, Once upon a time [Robbo1Mark--aol--com] spoketh thus: <...>
> I think I lean towards the zero position. For > instance 'HEAD is always index 1 whereas 'TAIL > is always ( index? last + 1 ), I see 'TAIL as > being correct because it is the position after > the last element of a series!
Yup.
> If you accept that as true then surely 'HEAD of > a series! should be index position zero, agreed?
No. Imagine a queue at a ticket counter: There's someone at the HEAD of the queue, that's the FIRST (1), there's a LAST one, he's at the position length of the queue, and there's the TAIL of the queue, where you have to stand, if you are coming now, that's length + 1. length of queue now, 4 people _____ / \ o o o o o Tickets /O\ /O} {O} /O\ /O\ | | / \ / \ / \ / \ / \ | | | coming late goint to the tail at the head the last will be last position 1 position 4 position 5
> In my view this should be the "correct" behaviour > > >> index? head [a b c] > == 0 > > My Reasoning being 'INSERT joins values to the head > of a series! "before" the first element.
Given these three things on a table apple mushroom orange please insert a glass_of_water at the position of the apple glass_of_water apple mushroom orange now please insert a spoon at position 1 spoon glass_of_water apple mushroom orange looks pretty correct and simple to me.
> With regards to me "giving" 'PICK the ability to > accept NONE as an index position, this was only > done for example purposes to highlight a further > inconsistency in REBOL. > > The Conditional Functions like 'IF & 'EITHER accept > NONE as the logical equivalent of 'FALSE. > > >> either none [ true ] [ false ] > == false > > Therefore if you can do this.... > > >> pick [true false] false > == false > >> pick [true false] true > == true > > Then why not this...... > > >> pick [true false] none > == false > > After all..... > > >> to-logic none > == false > > Either 'none is the logical equivalent of 'false or > it isn't? As it currently stands as these examples show > that this is the case except when it's not! and that > hardly leads to consistency, clarity or ease of learnability > and understanding.
That's ok so far ...
> I think for clarity & consistency & simplicity this should > be the case...... > > FALSE = NONE = 0 > > Reasoning... > >> to-logic none > == false > >> to-logic 0 > == false > >> to-integer false > == 0 > >> to-integer none > == 0 > > And if you give 'PICK the ability to utilise logic! or > conditional values then saying > > >> pick [true false] false > == false > >> pick [true false] 0 > == false > >> pick [true false] none > == false > > IMHO Should be the "correct" behaviour however ally that to > zero indexing for series! and preferably you would > have this as the "correct" behaviour.... > > >> pick [false true] false > == false > >> pick [false true] 0 > == false > >> pick [false true] none > == false > >> pick [false true] true > == true > >> pick [false true] 1 > == true > > Simple, Consistent & easy to learn & remember!
Except whene it's not:
>> if true [true]
== true
>> either true [true][false]
== true
>> either false [true][false]
== false The "trueth" comes first here, and the "falseth" last, like in pick, if find that "Simple, Consistent & easy to learn & remember!" (quoting somone on this list ;-) <...>
> For me 'First is logically simple and compatable with Index position > zero.
<...>
> REBOL 2.x came into being in 1998 so that is only 3 years > backwards compatability. Surely we expect REBOL 3++ to be around a LOT > longer than that, IMHO better to change now / then than live with > inconsistency / the "wrong" way forever! And That is the Microsoft Way!
<...>
> > The zero element of a series does not exist. > > Unless you've programmed C for the best part of a decade, in which case > all this talk of starting arrays and series at 1 takes a bit of getting > used to.... ;)
Just because people are gotten used to the braindead C, REBOL doesn't have to follow the wrong way, too. Well, that's my opinion. Interestingly the only real advantage of zero based indexing hasn't been stated this time around, the dicontinuity in pick ...
>> a: [ a b c]
== [a b c]
>> a: next a
== [b c]
>> pick a 1
== b
>> pick a 2
== c
>> pick a -1
== a
>> pick a 0
== none kinf regards, Ingo