Howdy Keith:
> How is data passed back and forth into and out of
> functions? Are copies made when passing data in or are they
> passed 'by reference', or are sequences passed by reference
> and values passed by value?
You can think of them as passed by reference, copies are not
made. You can verify this with a little experimentation:
f: func [x [series!]][append x now]
z: "The time is "
f z
Examining z you find that it has been modified by the
function f.
> How would I construct a "seventh" word that would basically
> give me the 'second' of what would be given after I got the
> 'fifth' of a sequence?
seventh: func [x [series!]][x/7]
seventh [one two three four five six seven]
== seven
> Why was the design choice made to make all words sort of be
> in a global scope, and then have to explicitly say 'use' to
> have local variables or words, rather than just making any
> new words defined in a function be local unless explicitly
> stated otherwise? This seems dangerous. At least Perl has
> 'use strict' to make you be careful with stuff like that.
Words can have limited scope in functions also by being
listed as a parameter. A tactic for making local variables
is thus:
f: func [/local1 local2 local3][
foreach local [local1 local2 local3][
print value? local
]
]
f
(output is true true true)
foreach local [local1 local2 local3][
print value? local
]
(output is false false false)
Refinements and parameters that follow refinements are
optional arguments, so they serve to create local variables
for you. The mezzanine FUNCTION takes a block of words that
you want to be local to the function following the parameter
block (before the body of the function) and actually sticks
the words into the spec block after the refinement
/local. (Do a SOURCE FUNCTION to see.) The iterators also
create local variables (as the variable 'local with
foreach.) Objects also create limited scope. And of course
scope can be limited using the native USE.
> I'd like to know if and how REBOL handles the more complex
> tasks in OOP.
Such as?
Salud--
-jeff