Hi, Ladislav and Romano

Ladislav Mecir wrote:
> 
> Hi Romano,
> 
> <<Romano>>
> 
> >> a: func[][make error! "p"]
> >> b: func[][return make error! "p"]
> >> error? a
> ** User Error: p
> ** Near: make error! "p"
> >> error? b
> == true
> 
> >> a: func[][first [p:]]
> >> b: func[][return first [p:]]
> >> a
> == p:
> >> b
> == p
> 
> (...)
> <</Romano>>
> 
> The first sample:
> 
> My POV is, that the first sample's function A should behave
> exactly like the first sample's function B...
> 
> The second sample:
> 
> ... I think, that this is a bug (discovered by you).
>

Based on the documented (RCUG) meaning of RETURN, I agree
with Ladislav that both examples demonstrate bugs in REBOL.

    As you know from the Expressions Chapter, blocks return
    their last value when they return from evaluation: 

        do [1 + 3  5 + 7]

        12

    This is also true for functions. The last value is returned
    as the value of the function: 

        sum: func [a b] [
            print a
            print b
            a + b
        ]

        print sum 123 321

        123
        321
        444

    In addition, the return function can be used to stop the
    evaluation of a function at any point and return a value...

The verbiage and examples lead me to conclude that the only
difference between explicitly RETURNing a value and implicitly
returning the last value is that RETURN may be used to exit
"prematurely" at any point within the function.  Nowhere that
I can find does the documentation state (nor imply) that

    f: func [...]
    [    ...
         some-expression
    ]

should be any different in value nor effect from

    f: func [...]
    [   ...
        return some-expression
    ]

(particle physics notwithstanding... ;-)

-jn-

-- 
; sub REBOL {}; sub head ($) {@_[0]}
REBOL []
# despam: func [e] [replace replace/all e ":" "." "#" "@"]
; sub despam {my ($e) = @_; $e =~ tr/:#/.@/; return "\n$e"}
print head reverse despam "moc:xedef#yleen:leoj" ;
-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to