Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: Path Access Problem

From: joel:neely:fedex at: 16-Nov-2000 13:11

Hi, Rodney, This is another interesting REBOL-ism that just has to be learned. [rebol-bounce--rebol--com] wrote:
> When I access a value in a block via a path, the > value seems right but the type does not. > > >> m: [b false] > == [b false] > >> probe m/b > false > == false > > Looks ok so far, BUT > > >> type? m/b > == word! > > which means that things like this don't work: > > >> if m/b [print "what?"] > what? > >> > > Is there a way to make this work? >
The type and value are both right, you just have to redefine the meaning of "right" ;-) Seriously, take a look at this
>> m: [b false]
== [b false]
>> foreach item m [print [item type? item]]
b word false word The value of m is a block that just contains two words. However, 'false is a word whose value is preset to the logic! value of untrue (also the value of words spelled "no" and "off"). To get the behavior you're wanting, you need to initialize your block to associate the word b with the logic value of false. For example:
>> m: reduce ['b false]
== [b false]
>> either m/b [print "Yup!"] [print "Nope!"]
Nope! or
>> m: reduce ['b 1 < 2]
== [b true]
>> either m/b [print "Yup!"] [print "Nope!"]
Yup!
>> m: [b none]
== [b none]
>> m/b: 0 = 1
== [b false]
>> either m/b [print "Yup!"] [print "Nope!"]
Nope! Remember, REBOL is a *very* "literal-minded" language! ;-) -jn- -- ; Joel Neely [joel--neely--fedex--com] 901-263-4460 38017/HKA/9677 REBOL [] foreach [order string] sort/skip reduce [ true "!" false head reverse "rekcah" none "REBOL " prin "Just " "another " ] 2 [prin string] print ""