07 Jul, 2009, Stormy wrote in the 21st comment:
Votes: 0
Oops, been awhile since I looked at it. That answers that.
07 Jul, 2009, Tyche wrote in the 22nd comment:
Votes: 0
IIRC, a function defined at the top level like..

def world
World.instance
end

is equivalent to..

class Object
private
def world
World.instance
end
end
07 Jul, 2009, Tyche wrote in the 23rd comment:
Votes: 0
David Haley said:
Is that actually true – that all function calls are by reference? My understanding was that things are passed around by value, but that most (all?) values are references to things.


Right. Functions calls are references passed by value. :-/
So foo(bar) creates a new reference variable in the function pointing to what bar pointed to.

Assignment points the local reference to something else.

This can be tricksy with integers because there are no functions that modify them through the reference, because they aren't actually independent objects that can be referenced under the covers.

Thus it's quite impossible to write stuff like the following C fragment (for integers that is).

foo(int *i) {
*i = 1;
}
07 Jul, 2009, David Haley wrote in the 24th comment:
Votes: 0
I thought that you could achieve that fairly easily with a wrapper class around the number one way or another, kind of like what a mutable Integer class might look like in Java. It's non-obvious, though, I'll definitely agree. And you wouldn't be able to use actual assignment.
07 Jul, 2009, Runter wrote in the 25th comment:
Votes: 0
Any immediate object isn't stored by reference. Nor is the reference passed.
Integers are immediate objects whereas most (all?) other objects are not.

edit:
Fixnum, Symbol, true, false, and nil are all examples of immediate objects.
/edit

So for one of these immediate objects to have a reference passed an object with a reference to this immediate object must be passed.
Example of a fast way to get the same effect follows:

def roar arr
arr[0] = 1
end

i = 0
roar [i]
### i is now 1


Also, keep in mind:
foo(int *i) {
*i = 1;
}


*i = 1; is indeed the same thing as i[0] = 1;
07 Jul, 2009, David Haley wrote in the 26th comment:
Votes: 0
Is the "immediate object" Ruby's version of a "primitive value"?
07 Jul, 2009, Runter wrote in the 27th comment:
Votes: 0
David Haley said:
Is the "immediate object" Ruby's version of a "primitive value"?


Yes, but for the user they will behave as objects just the same.

10.times do 
##meh
end


To the user they aren't primitives and are part of a class that is extendable, reflective, and introspective just the same.

Fixnum objects are unique and immutable, so every '5' in the system is the same Fixnum instance with the same oid.
07 Jul, 2009, Runter wrote in the 28th comment:
Votes: 0
I should also say that once a Fixnum has a value outside of its operation it becomes a Bignum instance.
Bignum and Fixnum implement the same methods.
Which is indeed its own instance—

i1 = 0
i2 = 0 ### shared Fixnum instance with i1

b1 = 2**1000 ### 2 ^ 1000
b2 = 2**1000 ### unique Bignum instance from b1


Interestingly, though, Bignum instances behave in similar way to immediate objects to follow the principle of least surprise.
20.0/28