Hi Joel,

I am not glad, that I must disappoint you, but see the following example:

a: 1
b: to paren! [to paren! [to paren! [to paren! [a: 0 - a]]]]
ifs-for-dummies b [negative: ["Negative"] zero: ["Zero"] positive:
["Positive"]]
== "Zero"

I think, you should read Exception #5 for Word Evaluation of my Rebol/Core
User's
Guide Comments once again and hope, that this will be interesting even for
others...

Regards
    Ladislav

P.S. My strong opinion is, that the best you can get is:

signed-if: func [
    {If positive do positive-block, zero do zero-block, negative do
negative-block}
    [throw]
    condition [number! char! money! time!]
    positive-block [block!]
    zero-block [block!]
    negative-block [block!]
] [
    either positive? condition [do positive-block] [
        either negative? condition [do negative-block] [do zero-block]
    ]
]

I am afraid, that Signed-if-for-dummies may become a victim of the GC bug
and similar issues, when used recursively...

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, October 11, 2000 11:20 PM
Subject: [REBOL] Ifs Re:


> Hi, all...
>
> In honor of the newest REBOL book (and for those of us who can't count to
> three in proper order, such as myself! ;-) and inspired by the keywords
> feature of Common Lisp, I offer yet another   ifs   , which doesn't care
> in which order the actions are specified:
>
>   >> a: 1
>   == 1
>   >> ifs-for-dummies a [positive: ["plus"] zero: ["zip"] negative:
["minus"]]
>   == "plus"
>   >> ifs-for-dummies a [zero: ["zip"] positive: ["plus"] negative:
["minus"]]
>   == "plus"
>   >> ifs-for-dummies a [negative: ["minus"] zero: ["zip"] positive:
["plus"]]
>   == "plus"
>
> whether they are all specified:
>
>   >> ifs-for-dummies a [positive: ["biggerthanzero"]]
>   == "biggerthanzero"
>   >> ifs-for-dummies a [negative: ["smallerthanzero"]]
>   >> ifs-for-dummies a [zero: ["equaltozero"]]
>   >> ifs-for-dummies a [zero: ["equaltozero"] positive: ["bigger,
again!"]]
>   == "bigger, again!"
>
> or whether the selector has unstable side-effects:
>
>   >> a: 1
>   == 1
>   >> b: to-paren [a: 0 - a]
>   == (a: 0 - a)
>
>   >> ifs-for-dummies b [negative: ["minus"] zero: ["zip"] positive:
["plus"]]
>   == "minus"
>   >> ifs-for-dummies b [negative: ["minus"] zero: ["zip"] positive:
["plus"]]
>   == "plus"
>   >> ifs-for-dummies b [negative: ["minus"] zero: ["zip"] positive:
["plus"]]
>   == "minus"
>   >> ifs-for-dummies b [negative: ["minus"] zero: ["zip"] positive:
["plus"]]
>   == "plus"
>
> This new candidate (which will run if evaluated, but not if elected), has
a
> running mate:
>
>   fortranif: make object! [
>       positive: []
>       negative: []
>       zero:     []
>       selector: 0
>       compute:  func [[throw] selexpr] [
>           selector: selexpr
>           either positive? selector [
>               do positive
>           ][
>               either negative? selector [
>                   do negative
>               ][
>                   do zero
>               ]
>           ]
>       ]
>   ]
>
> and a campaign promise:
>
>   ifs-for-dummies: func [[throw] selexp conseq [block!] /local actor] [
>     actor: make fortranif conseq
>     actor/compute selexp
>   ]
>
> (In case you're wondering, the news coverage of the US election campaigns
> hasn't affected me at all!  "My fellow REBOLians...")
>
> -jn-
>
> "Coding at the speed of a dummy!"
>
> --
> ; Joel Neely  [EMAIL PROTECTED]  901-263-4460  38017/HKA/9677
> REBOL []  print to-string debase decompress #{
>     789C0BCE0BAB4A7176CA48CAB53448740FABF474F3720BCC
>     B6F4F574CFC888342AC949CE74B50500E1710C0C24000000}
>
>

Reply via email to