Hello [EMAIL PROTECTED]!

On 22-Gen-00, you wrote:

 j> I have a general comment about this thread. It seems to me to
 j> point up the difficulty of writing first-class control
 j> structures in REBOL. I haven't seen in this thread (nor have I
 j> been able to think of) an approach that actually behaves as
 j> well as a native control structure.

I think it is feasible.

 j> I get the following:

 j>>> testcase2
 j>    1 = 1
 j>    ** Script Error: result needs a value.
 j>    ** Where: result: do blk

 j> due to the fact that  print  doesn't return a result:

 j>>> foo: print 123
 j>    123
 j>    ** Script Error: foo needs a value.
 j>    ** Where: foo: print 123

Can be fixed using:

    set/any 'foo print 123

 j> [EMAIL PROTECTED] wrote:

I prefer the version corrected by Ladislav.

 j> Again, a nice piece of code, but look what happens with

 j>    paranoid1: func [a b] [
 j>        do-cases [
 j>            a <= 0 [return 0]
 j>            b <= 0 [return 0]
 j>            else   [print "OK"]
 j>        ]
 j>        print "Computing now!"
 j>    ]

This can be handled by the function attribute 'throw. You can
write 'do-cases as:

    do-cases: func [
        "Executes the case whose condition is true"
        [throw]
        ...

With 'throw any 'return or 'exit will be passed along to the
caller.

Regards,
    Gabriele.
-- 
o--------------------) .-^-. (----------------------------------o
| Gabriele Santilli / /_/_\_\ \ Amiga Group Italia --- L'Aquila |
| GIESSE on IRC     \ \-\_/-/ /  http://www.amyresource.it/AGI/ |
o--------------------) `-v-' (----------------------------------o

Reply via email to