[REBOL][logic!] another bug ?
[1/6] from: Christophe:Coussement:mil:be at: 23-Jul-2004 11:26
Hi list, As I was converting XML data to REBOL datatypes, I struggeled on this one: REBOL/View 22.214.171.124.1 6-Aug-2003 Copyright 2000-2003 REBOL Technologies. All rights reserved. REBOL is a trademark of REBOL Technologies. WWW.REBOL.COM
>> to-logic "true"
== true ;==> ok
>> to-logic "false"
== true ;==> yerk
>> make logic! "false"
== true ;==> yerk again
>> to-logic 'false
== true ;==> etc... If it isn't a bug, what's the point of 'to-logic, other than:
>> to-logic 1
>> to-logic 0
== false =xtof
[2/6] from: rotenca:telvia:it at: 23-Jul-2004 12:35
Hi Christophe, AFAIK, only 0, false and none return false, any other rebol datatype (also the word 'false] return true. The content of string is not considered at all. If you want to interpret the content of a string you must use: do load/all "false" or: first load/all "#[false]" --- Ciao Romano
[3/6] from: carl:cybercraft at: 23-Jul-2004 22:35
>Hi list, >As I was converting XML data to REBOL datatypes, I struggeled on this one:
<<quoted lines omitted: 14>>>>> to-logic 0 >== false
I don't think it's a bug, just that most values are true, such as strings, even when empty or containing "false". It's getting the logic of the value, not converting it. With 0 being an exception to this rule, obviously...
>> either 0 ["0 is true!"]["0 is false!"]
== "0 is true!"
[4/6] from: greggirwin:mindspring at: 23-Jul-2004 8:41
>>> to-logic "false"
== true ;==>> yerk From the Core guide: "Just about any value assigned to a word has the same effect as true:" Romano pointed out the other important thing; LOAD it. -- Gregg
[5/6] from: antonr:lexicon at: 26-Jul-2004 0:35
I suppose you already have a solution, but maybe it looks better to do this:
>> get to-word "false"
>> get to-word "true"
== true Anton.
[6/6] from: Christophe::Coussement::mil::be at: 26-Jul-2004 8:43
Hi Anton, Gregg, Carl and the friendly others
> I suppose you already have a solution, > but maybe it looks better to do this: > > >> get to-word "false" > == false > >> get to-word "true" > == true
Cool ! I did get this one. My solution was less elegant: to-logic*: func [val [string!]][ return switch/default val ["false" [false] "true" [true]][none] ] I learn every day thanks to you all ;-)) ==xtof
- Quoted lines have been omitted from some messages.
View the message alone to see the lines that have been omitted