Truth and lies (but no statistics) [was Re: WYSIWYG programming]
[1/2] 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
<<quoted lines omitted: 4>>
> 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
to ask for greater-to-lesser ordering.
>> 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 ]
[2/2] from: lmecir:geocities at: 30-Oct-2000 22:12
Hi Joel,
you inspired me (like you did many times before) to write:
le?: function [
{an as general as possible comparison function}
a [any-type!]
b [any-type!]
] [block1 block2] [
block1: make block! 2
insert/only block1 get/any 'a
insert/only tail block1 get/any 'b
block2: make block! 2
insert/only block2 get/any 'a
insert/only tail block2 get/any 'b
block1 = sort block2
]
the results:
>> le? 1 2
== true
>> le? 2 1
== false
>> le? true false
== false
>> le? false true
== true
>> le? true none
== false
>> le? none true
== true
>> le? none ()
== false
>> le? () none
== true
>> le? does [a] does [b]
== true
>> le? does [b] does [a]
== true
>> le? make object! [a: 0] make object! [a: 1]
== false
>> le? make object! [a: 1] make object! [a: 0]
== true
>> le? make object! [a: 0] make object! [a: 0]
== false
Regards
Ladislav
----- Original Message -----
From: Joel Neely <[joel--neely--fedex--com]>
To: <[rebol-list--rebol--com]>
Sent: Monday, October 30, 2000 8:42 PM
Subject: [REBOL] Truth and lies (but no statistics) [was Re: WYSIWYG
programming]
Notes
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted