Are you sure Xavier?
I am afraid that in
def x b
b = ...
you brake the link as shown in the diagram (somehow as having a local
variable shadowing the param)
because if you made
def x b
b << "hello"
the diagram seems correct, or is it I who misses something here?
Cheers
R.
···
On Fri, Nov 12, 2010 at 12:38 PM, Xavier Noria <fxn@hashref.com> wrote:
On Fri, Nov 12, 2010 at 12:25 PM, Josh Cheek <josh.cheek@gmail.com> wrote:
On Fri, Nov 12, 2010 at 3:01 AM, Xavier Noria <fxn@hashref.com> wrote:
When the function is invoked the pointer is *copied*, that is, an integer
value is copied and linked to a local variable. The exact same thing
happens if the parameter is int i.The exact same thing also happens with a reference (at least in C++, I don't
know anything about Perl).The pointer value is copied into the number variable (pass by value).
You can be certain the caller sees the exact same pointer when
the function call returns.Please re-read your blog with this in mind, since what you right here in
this quote are calling "pass by value" you, in your blog, call
"pass-by-reference".ImageShack - Best place for all of your image hosting and image sharing needs
No, no. If Ruby did what the diagram shows the program
def m(b)
b = Object.new
p b.object_id
enda = Object.new
m(a)
p a.object_idwould print the same number because a and b would be pointing to the
same storage area. They aren't.
--
The 1,000,000th fibonacci number contains '42' 2039 times; that is
almost 30 occurrences more than expected (208988 digits).
N.B. The 42nd fibonacci number does not contain '1000000' that is
almost the expected 3.0e-06 times.