[REBOL] Re: [none idiom found?] The best shortcut word for "not none?"
From: greggirwin::mindspring::com at: 4-Sep-2006 11:36
Hi Ladislav,
>> c) TO LOGIC! does not behave exactly like FOUND? sometimes. See TO
>> LOGIC! FALSE and the question is, which result is appropriate for the
>> specific usage. For the above use this question is unimportant, but it
>> may occur elsewhere.
>>
LM> there is one *important* difference I overlooked, though:
LM> to logic! 0 ; == false
OK, so 0 and false are where things differ between FOUND? and To
LOGIC!; in both cases, FOUND? returns true while TO LOGIC! returns
false.
I think the key phrase is "appropriate for the specific usage"; but we
also have to consider your point below about SELECT/SWITCH.
LM> Speaking of which, I would prefer a different behaviour, what do
LM> you think?
I understand the reason for it--mapping to C BOOL values of 0 and
1--and I think it's probably most useful the way it is now, from a
pragmatic point of view.
LM> found? select [1 #[none]] 1
>> , which is related to the question, what you expect when writing:
>>
LM> switch/default 1 [1 #[none]] [2]
This is a *really* good question. I'm always amazed at the behavior
we find that you might think would be a problem, but isn't, in
practical use. I don't know that I've ever been bitten by the above,
but it seems like an obvious flaw when you look at it that way.
Maybe this would be a good question for a blog post by Carl. I
remember him saying once that FORALL and FORSKOP were originally
intended as macros for WHILE, hence leaving the series at the tail. I
wonder if the original goal for FOUND? considered its use with ANY and
ALL, logic results, or just the result of FIND; and does SWITCH work
that way by design, or was it just a convenient implementation with
very little risk (i.e. expected behavior) in everyday use.
-- Gregg