[REBOL] Re: Does the REBOL book clarify REBOL semantics?
From: lmecir:mbox:vol:cz at: 22-Nov-2000 22:02
Hi,
> At 16:05 21/11/00 +1300, Andrew Martin kindly replied:
>
> [snip]
>
> >Either the argument is a series! or a object! then it's passed as a
pointer,
> >otherwise it's passed as a copy. Check out pages 87 through 90 of the
Core
> >manual PDF for more.
>
> So series' and objects are passed by ref while all else are
> passed by copy?
>
My point of view differs a lot here.
Statement #1: * In Rebol all arguments are passed by value, regardless of
their type. *
proof: function [argument] [check] [
check: func [arg] [
print ["Arg:" mold arg]
arg: either arg = true [false] [true]
print ["Changed arg:" mold arg]
]
print ["Argument supplied:" mold argument]
check argument
print ["Argument after return:" mold argument]
]
>> proof true
Argument supplied: true
Arg: true
Changed arg: false
Argument after return: true
>> proof false
Argument supplied: false
Arg: false
Changed arg: true
Argument after return: false
>> proof [1 2]
Argument supplied: [1 2]
Arg: [1 2]
Changed arg: true
Argument after return: [1 2]
The above means, that the Rebol argument passing mechanism is
uninteresting
from this point of view. The next natural question may be:
Are the benefits of "By Reference Argument Passing" lost for the Rebol
users?
The answer sounds: "No", and here is why:
Statement #2: * Some Rebol values can reference other Rebol values. *
Examples:
a) A Rebol word can reference the value the word "contains".
b) A Rebol series can reference the values the series "contains", moreover,
it can even reference all the values its head series contains.