On Friday 02 April 2004 2:43 pm, David King Landrith wrote:
>  From what I understand, since 12 is a FixNum, a and b end up being
> separate FixNum objects with their own separate values of 12.  But this
> strikes me as beside the point.

This is incorrect.  a and b would both point to the same FixNum object.
In fact, I wouldn't be surprised if all direct references to 12 were the same
FixNum object for efficiency purposes.

> In the C api, each function gets passed a pointer to the struct which
> represents self.  You can pass this pointer to any number of functions
> to get information about self; e.g., class along with variables and
> their contents.  So that for the FixNum 'a' above, we could discern
> that it was a FixNum.  The question is: Is there a method that wil tell
> me that it is called 'a'.  If 'self' end up being a literal, then I
> suppose its name is its value, but it seems to me that this would
> simply be a question of how the interpreter works vis a vis its symbols
> table.

The name of the variable that points to the object isn't an inherent part
of the object, though.  Like above, you can have any number of variables
representing the same object.  Also, you could have many objects referencing
that same object (for example, if it's stored in an array).  Should an object
also keep references to all objects that reference it?

Variable names are incidental. For example:

def foo
	a = String.new
end

x = foo

When inside the method foo, the string is pointed to by the local variable a.
However, outside, it's pointed to by the local variable x. What has changed
about the object? Nothing.

Variables are a lot like pointers in C.  You allocate a pointer to store the
address of some other memory. It doesn't make sense for every piece of
memory to also store the addresses of all pointers that point to it.

- Dan