Thanks for your patience. I do understand what
Andrew is saying. But maybe you guys can then
explain the following behavior. Type the following
into a script and 'do it:
REBOL[]
print-val: func [val [any-type!]] [
print either value? 'val [val]["No value given"]
]
print-val 1234
print-val
print "DONE"
print "WHAT?"
On my system (NT, latest /View) I see printed:
1234
DONE
No value given
WHAT?
How is "No value given" being printed after "DONE"?
Sorry if I'm being obtuse here but this just seems wrong.
Also, refinements aren't exactly the same as optional
arguments - you'll always have to pass a dummy argument
along with a refinement. But it will work fine.
Thanks for the help,
Rodney
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Thursday, June 22, 2000 10:18 AM
To: [EMAIL PROTECTED]
Subject: [REBOL] Optional Arguments Working? Re:(6)
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 23, 2000 2:43 AM
Subject: [REBOL] Optional Arguments Working? Re:(5)
> You must perform your test in a script file and
> 'do it to see the bug. The bug does not occur
> in a console session.
>
> Rodney
>
It is not a bug, see Andrew's explanation from the bottom of the message.
The safer way to have optional arguments is to use refinements.
Cheers,
Allen K
> Note that Rebol evaluates the arguements to a function before calling the
> function. In this case:
> f f f f f f halt
> the 'halt is evaluated just before evaluating the last (or first in
> reverse order) 'f function. 'halt has the side effect of stopping
execution
> of Rebol, so the last 'f is not evaluated.
>
> I hope that helps!
>
> Andrew Martin