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

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

From: kenneth:nwinet at: 2-Jul-2001 21:14

FWIW, I'd like to add my voice... If I'm counting something I may have one of them, but if I'm ordering something the first element has to be zero. Starting the count from 1 is as arbitrary as starting at negative five (other than the direct mapping to a count) in all other cases I can think of, starting from zero produces cleaner code. I think the Roman numeral analogy is more than apt. Backward compatability is more an issue with a scripting language, but I'd hope for a number of reasons that a switch option base not be added. Consider my chad to be completely removed on this point (as if I had a vote ;-) Mapping True/False to numbers? If we can ignore the pesky undefines then the universal set can either be defined as (true and not true) or (false and not false.) Of course, it doesn't have to be integers we map to... True [ 42, 3.14159, www.rebol.com ] everything else is False! Then we have the rebol way... both zero and one are true! not 0 ; = false not not 0 ; = true not 1 ; = false not not 1 ; = true then again this works for any defined value AFAIK. And along with Or seem to work in a bitwise fashion so I don't believe they can be used to prove anything regarding rebols mapping of values to booleans. My guiding principle is what leads to cleaner code so I'd look for counter example to using an integer zero for false and anything else for true. Bitwise logic can't be used here because it doesn't promote the value to a true boolean before performing it's action leading to apparent inconsistancies (ANDing two or more true values may result in a false.) 1 and 2 ; = false So my question is, how does a boolean value that doesn't map to integers have any validity with regard to a series? Why wouldn't it lead to a scripting error rather than some arbitrary behavior? It seems to me there is an implied mapping in this train of thought.... a: [1 2 3] pick a 1 ; = 1 pick a false ; = 1 pick a 2 ; = 2 pick a true; = 2 What do I see? Looking at it slideways I see false = 0 and true = 1 and a series being counted with the first element being the zeroth. What sees the light of day may be another matter. Does this make sense to anyone else? Regards, Ken.