Mailing List Archive: 49091 messages

## [REBOL] Truth and lies (but no statistics) [was Re: WYSIWYG programming]

### From: joel::neely::fedex::com at: 30-Oct-2000 13:42

```
Hello, yet again...

[jeff--rebol--net] wrote:
> > >
> > >   EITHER  places  the TRUE  block first,  the  ELSE/FALSE
> > >   block second. Pick thinks of TRUE/FALSE in that way.
> > >
> >
> > I don't see EITHER and PICK  as analogous...
>
>   Okay, so you would like the following:
>
>   pick ...
>

Let's separate these two (semi-siamese-twin) issues:

1)  Current order-comparison operators refuse to compare logic! values.

2)  Pick some-block some-logic identifies TRUE <-> 1 and FALSE <-> 2.

ON ORDERING LOGIC! VALUES (#1)

Given the facts that

0       <      1                 0       <      1
to-decimal     to-decimal         to-char        to-char
0.0      <     1.0              #"^@"     <    #"^A"
to-integer     to-integer        to-integer     to-integer
0       <      1                 0       <      1

it seems inconsistent that

0              <             1
to-logic                     to-logic
false     *NOT ORDERABLE*     true
to-integer                   to-integer
0              <             1

especially since REBOL really does have some idea of the order of logic!
values (false < true), since sort treats them consistently

>> sort [1 0 0 1]                         == [0 0 1 1]
>> sort [1.0 0.0 0.0 1.0]                 == [0 0 1 1]
>> sort reduce [true false false true]    == [false false true true]

However, sorting breaks down when we use the /compare refinement simply

>> sort/compare [1 0 0 1] func [a b] [a > b]
== [1 1 0 0]
>> sort/compare [1.0 0.0 0.0 1.0] func [a b] [a > b]
== [1 1 0 0]
>> sort/compare reduce [true false false true] func [a b] [a > b]
** Script Error: Cannot use greater? on logic! value.
** Where: a > b

This would all be fixed if we could simply compare logic! values with
the ordering (consistently implied from all of the above) false < true.

ON PICK #2

Well, there's clearly a conflict with having FALSE correspond to 0 and
having it serve as a legal "index" for PICK at all!  This arises from
the design choice to have position numbers start at 1.

Under the legacy of that decision, I would suggest as a "lesser of the
evils" compromise (assuming > and < are defined for evil! types ;-) of
allowing relational operators < <= > and >= to compare logic! values
and changing nothing else.

Those who don't care about comparisons of logic! values will be un-
affected by this solution, and it will not break any existing code.

ON NONE

I am deferring the separate (although related) discussion of none to
another email (in the interest of brevity, etc.)  Suffice it to say
that none! and logic! are distinct types, and I never asked to have
comparison between different types.

-jn-

--
; Joel Neely  [joel--neely--fedex--com]  901-263-4460  38017/HKA/9677
REBOL [] do [ do func [s] [ foreach [a b] s [prin b] ] sort/skip
do function [s] [t] [ t: "" foreach [a b] s [repend t [b a]] t ] {
| e s m!zauafBpcvekexEohthjJakwLrngohOqrlryRnsctdtiub} 2 ]
```