Hi,

a stupid example:

f: func [x [any-type!]] [1]
b: to paren! [to paren! [:f]]
ifs-for-dummies-who-play-with-fire b [positive: [print "positive"] negative:
[print "negative"] zero: [print "zero"]]

The result:

zero
== 1

Regards
    Ladislav

> [EMAIL PROTECTED] wrote:
> >
> > Hi Joel,
> >
> > I am not glad, that I must disappoint you, [...]
> >
>
> Not at all!  It's just that I, being a Bear of Small Brain, find it
> difficult to give up.  I'm very appreciative of the feedback!
>
> I've forgotten the source, but recall the saying, "In science, a
> successful experiment teaches nothing, as only the expected result
> is obtained.  One learns only when an experiment fails, providing a
> challenge for new thought."
>
> Thanks for the excellent teaching!
>
> > 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 [...]
> >
>
> Have done.
>
> >
> > and hope, that this will be interesting even for others...
> >
>
> I also.
>
> Trying yet again, (I'm running the risk of keeping two distinct issues
> entangled here -- the get-to-the-bottom-of-a-strange-selector puzzle,
> and the object-for-named-parameters gimmick)...
>
>     unravel: func [[throw] exp /local val] [
>         val: exp
>         while [not any[ number? val  char? val  money? val  time? val]]
> [
>             val: do val ]
>         val ]
>
>     signed-choice: make object! [
>         positive: []
>         negative: []
>         zero:     []
>         selector: 0
>         compute:  func [[throw] selexpr] [
>             selector: unravel selexpr
>             either positive? selector [
>                 do positive
>             ][
>                 either negative? selector [
>                     do negative
>                 ][
>                     do zero
>     ]   ]   ]   ]
>
>     ifs-for-dummies-who-play-with-fire: func [
>         [throw] selexp conseq [block!] /local actor
>     ][
>         actor: make signed-choice conseq
>         actor/compute selexp ]
>
> After which I can conduct more experiments...
>
>     >> c: [{[{[{"-1"}]}]}]
>     == [{[{[{"-1"}]}]}]
>     >> ifs-for-dummies-who-play-with-fire c [
>            positive: ["+"] negative: ["-"] zero: ["0"]]
>     == "-"
>     >> c: [{[{[{"1"}]}]}]
>     == [{[{[{"1"}]}]}]
>     >> ifs-for-dummies-who-play-with-fire c [
>            positive: ["+"] negative: ["-"] zero: ["0"]]
>     == "+"
>     >> c: [{[{[{"2 - 2"}]}]}]
>     == [{[{[{"2 - 2"}]}]}]
>     >> ifs-for-dummies-who-play-with-fire c [
>            positive: ["+"] negative: ["-"] zero: ["0"]]
>     == "0"
>     >>
>
> >
> > I am afraid, that Signed-if-for-dummies may become a victim of the GC
bug
> > and similar issues, when used recursively...
> >
>
> I haven't had time to play with that issue, but will do so when I can.
>
> Thanks again!
>
> -jn-
>
>
>

Reply via email to