[REBOL] Re: Storing a logical condition
From: tim:johnsons-web at: 13-Oct-2003 13:01
Thanks to both Sunanda and Tom:
actually I found the following
either (do b)[...][...]
worked, but your inputs will help keep me out of trouble:
especially Sunanda's observations...
cheers!
tim
* [SunandaDH--aol--com] <[SunandaDH--aol--com]> [031013 12:51]:
> Tim:
> > What do I need to do so that my answer will be:
> > b evaluates to 'false'
>
> If a is still has a value, when you come to check the condition, then all you
> need is a do after the either:
>
> a: 1
> b: [a = 0]
> either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
> b evaluates to 'false'
>
> If a no longer has a value -- maybe it's been unset or is in another context
> -- then the above code won't work....
>
> a: 1
> b: [a = 0]
> unset 'a
> either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
> ** Script Error: a has no value
>
> ....In which case, you'll have wanted to evaluate the result and save it in b
> at the earlier opportunity:
>
> a: 1
> b: a = 0
> unset 'a
> either b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
> b evaluates to 'false'
>
> You could of course use this last possibility even if a still has a value --
> but it'll set b to the logical value at the time of the test, not the current
> value of a:
>
> a: 1
> b: a = 0
> a: 0
> either do b [print "b evaluates to 'true'"][print "b evaluates to 'false'"]
> b evaluates to 'false' ;; even though a = 0 right now
>
> Sunanda.
> --
> To unsubscribe from this list, just send an email to
> [rebol-request--rebol--com] with unsubscribe as the subject.
--
Tim Johnson <[tim--johnsons-web--com]>
http://www.alaska-internet-solutions.com
http://www.johnsons-web.com