ZERO-INDEX-PATCH.r
[1/4] from: robbo1mark::aol::com at: 5-Jul-2001 5:43
ZERO-INDEX-PATCH.r
Hello Idee ( that's JEFF in zero index alphabet 8-)
see I do have a sense of humour! well sometimes.
Everybody,
Now that we've all had a good debate / laugh about
zeroth's, offsets, squinty sideways zero's looking
like one's and gymnastic balancing pinkie coding
amendments to REBOL maybe it's time to bring some
closure to all of this.
As [Jeff--REBOL] suggested Iam proposing to write a
Zero-Index-Patch.r which will "Fix" REBOL and make
it's indexing work properly starting from zero like
all good languages should!
Why would I want to do this, well for "hack" value
alone it's worth doing! but also to show that it's
NOT as scary nor as BIG an undertaking as Jeff may
have lead us to believe.
I've included at the end of this mailing an amended
save-sources function definition which extends Elan's
function from the RTOG book to save to a file the
source / specs for ALL REBOL any-function! values
including native!, action! & op! types.
I did a quick check last night on the mezzanine function
sources and discovered that series! indexing func's like
'PICK, 'AT, 'SELECT etc aren't used as often as you might
think! less than twenty instances for each one if you
exclude their use as commentary in documentation strings.
I'm NOT going to get into a HOLY WAR about the merits of
ZEROTH or otherwise suffice to say that it's clear in my
mind that in a series of index numbers beginning at zero
(or any other number ie 7 ) I can show you the FIRST
element and the SECOND etc. I'd be hard pushed to show
you a ZEROTH element.
So for my purposes ZERO-INDEX-PATCH.r will operate on the
following assumptions.
1. Series will start from Index Position 0
2. First will STILL mean First Item of a series & ditto
for SECOND, THIRD, FOURTH etc.
examples.....
>> FIRST [a b c]
== a
>> PICK [a b c] 0
== a
>> SECOND [a b c]
== b
>> PICK [a b c] 1
== b
Does everybody get it?
This way seems perfectly clear, consistent, logical & easily
learnable, understandable & rememberable to me, and I suspect
other zero-indexers like Joel Neely & Ken Anthony etc.
If you don't get it, think of Joels twenty four hour clock
example where the hours number 0 through 24 and the minutes
and second number 0 through 59.
3. All zero based values will have LOGICAL equivalence.
This means that for INDEXING & CONDITIONAL functions like
PICK, AT, SELECT as well as IF & EITHER etc. will accept
the following.....
logic! FALSE = none! NONE = integer! 0 = decimal! 0.0
Here's some examples to help you understand...
>> pick [ a b ] 0
== a
>> pick [ a b ] false
== a
>> pick [ a b ] none
== a
>> pick [ a b ] 0.0
== a
>> pick [ a b ] true
== b
In the above examples the 'index arguments are coerced to
their logical equivalent integer! value ie either 0 or 1.
Similarly consider these...
>> if true [ true ]
== true
>> if 1 [ true ]
== true
>> if 3.141592 [ true ]
== true
>> either false [ true ] [false ]
== false
>> either none [ true ] [ false ]
== false
>> either 0 [ true ] [ false ]
== false
>> either 0.0 [ true ] [ false ]
== false
>> either 1 [ true ] [ false ]
== true
In the above examples the 'condition arguments are coerced
to their logical equivalent logic! values ie either true or false.
Now before anybody screams that the TRUE-BLOCK & FALSE-BLOCK's are
the wrong way round, well maybe so but the plan here is to keep them
in the above order as is in keeping with the common IF / ELSE BLOCK
ordering that is to be found in nearly ALL programming languages.
It is already well understood and widely used concept.
So that is the aims of ZERO-INDEX-PATCH.r
IF you accept the meaning of FIRST, SECOND, THIRD as I have outlined
above then only a much smaller percentage of existing REBOL code has
to be modified.
If you run the save-sources function then you can see for yourself
where the indexing & conditional functions are used in mezzanine source
code. Disclaimer, I've still to check SYSTEM object! ROOT-PROTOCOL &
NET-UTILS so they to will have to be audited & necessary changes made.
IF anybody else wants to join in with ZERO-INDEX-PATCH.r then please
make your interest known here on the list and hopefully we can work
together on re-defining the necessary functions, testing, debugging
and optimizing our code changes.
I think it would only take a day or two to identify & make the necessary
changes & recoding definitions, given some clear time to focus attention
on the problem, obviously it will take weeks / months to fully test and
debug and optimise ZERO-INDEX-PATCH.r however the more interest and help
to hand then the easier this should be.
WARNING! At the end of the day this will most probably be an exercise in
futility because I don't think RT Inc are going to make such a deep
change to REBOL at this stage, but maybe I'm wrong.
However If anybody else feels it would be a good thing or even a fun and
intersting thing to do then please let me know and post your comments
and suggestions here.
Cheers everybody / Idee ( Sorry I mean Jeff 8-)
Mark Dickson
----- REBOL SAVE-SOURCES FUNCTION DEFINITION ----------------------------------------
save-sources: func [filename [file!] /local words][
write filename "REBOL Sources: ^/^/"
words: load sort first system/words
foreach word words [
if all [value? word any-function? get word] [
either any [native? get word action? get word op? get word] [
write/append filename join word [": " mold get word " " mold third get word "^/^/^/"]
] [
write/append filename join word [": " mold get word "^/^/^/"]
]
]
]
]
[2/4] from: jelinem1:nationwide at: 5-Jul-2001 9:19
If RT fires Jeff and decides to implement zero-based indexing, that would
mean I'd have to write a ONE-INDEX-PATCH.r.
I count, therefore I am
- Michael Jelinek
[3/4] from: robbo1mark:aol at: 5-Jul-2001 10:45
Yes Michael you are quite right 8-)
BUT ? Are you COUNT'ed IN or OUT?
cheers, ;-|
Mark Dickson
In a message dated Thu, 5 Jul 2001 10:26:21 AM Eastern Daylight Time, [JELINEM1--nationwide--com]
writes:
<< If RT fires Jeff and decides to implement zero-based indexing, that would
mean I'd have to write a ONE-INDEX-PATCH.r.
I count, therefore I am
- Michael Jelinek
[4/4] from: jelinem1:nationwide at: 5-Jul-2001 10:13
If I reply to this, would I be writing spam?
- Michael
From: [Robbo1Mark--aol--com]@rebol.com on 07/05/2001 09:45 AM
Please respond to [rebol-list--rebol--com]
Sent by: [rebol-bounce--rebol--com]
To: <[rebol-list--rebol--com]>
cc:
Subject: [REBOL] Re: ZERO-INDEX-PATCH.r
Yes Michael you are quite right 8-)
BUT ? Are you COUNT'ed IN or OUT?
cheers, ;-|
Mark Dickson
In a message dated Thu, 5 Jul 2001 10:26:21 AM Eastern Daylight Time,
[JELINEM1--nationwide--com] writes:
<< If RT fires Jeff and decides to implement zero-based indexing, that
would
mean I'd have to write a ONE-INDEX-PATCH.r.
I count, therefore I am
- Michael Jelinek