Hi Terrence, you wrote:
>
>You would think REBOL would print out a bound function just as it did
>the bound value... otherwise you might think it has no value at all.
1. What you can do is use source, probe or print mold :f
>> f: func [x y] [x = y]
>> source f
f: func [x y][x = y]
>> probe :f
func [x y][x = y]
>> print mold :f
func [x y][x = y]
2. Printing a function like you would print a bound value:
Assuming x: 3
>> print x
3
What happens here?
a) REBOL dereferences print. Aha, a function requiring 1 argument. Let's
get the argument.
b) REBOL finds x. Aha, x is a word. Let's execute the word. (do x).
Executing x simply returns the value it is bound to.
d) Print receives the value 3 as its argument.
e) Print displays 3.
Assuming x: func [y] [y]
>> print x
a) Same as above.
b) REBOLs finds x. Aha, x is a word. Let's execute it. x requirest an
argument, y. There is no argument for x's y. Shucks. Error.
c) If there was an argument for x's y, then x would be executed, in our
case it returns the value y is bound to and print would happily print out
that value.
Why the difference?
When a word references a value other then a function, executing the word is
equivalent to retrieving its value using a colon:
>> x: 3
== 3
>> x = :x
== true
When a word references a function, then executing the word is different
from retrieving its value using the colon. Needless to say, executing the
word executes its instruction sequence, using a colon returns the function.
>> x: func [] [3]
>> x = :x
== false
Why false? Because :x returns the function x is bound to, x on the other
hand returns 3.
Elan