Home   Archive   Permalink



Careful when Construct an object

When you construct an object don't forget to use true/false for logic! values instead of using yes/no/on/off.
    
>> o: context [b: true]
>> ? o/b
O/B is a logic of value: true
    
>> o: context [b: yes]
>> ? o/b
O/B is a logic of value: true
    
>> o: construct [b: true]
>> ? o/b
O/B is a logic of value: true
    
>> o: construct [b: yes]
>> ? o/b
O/B is a WORD of value: yes
    
So, is this the only way to determine Yes is a word which has a value of logic true?

posted by:   Endo       5-Jul-2010/18:45:50-7:00



I usually mold/all for such things...
    
o: construct [ a: true b: yes c: on ]
    
>> print mold/all o
#[object! [
     a: #[true]
     b: yes
     c: #[true]
]]

posted by:   Maxim Olivier-Adlhoch       6-Jul-2010/1:59:51-7:00



Endo I think this is a bug as it is different in R3 when all are evaluated. I've posted a bug report to Rambo, the R2 bug database

posted by:   Graham       6-Jul-2010/2:51:39-7:00



I wrote this function:
    
f: func ['w] [type? get in construct compose [t: (:w)] 't]
    
here is the results:
    
>> f f
== word!
>> f :f
== function!
>> f print
== word!
>> f :print
== native!
>> f 5
== integer!
>> f yes
== word!
>> f true
== logic!

posted by:   Endo       6-Jul-2010/2:52:27-7:00



@Graham: I didn't know that.
I tried that function on R3 and yes, it behaves different:
    
>> f yes
== logic!
    
>> f true
== logic!

posted by:   Endo       6-Jul-2010/2:56:19-7:00