On May 5, 2007, at 6:02 PM, Rick DeNatale wrote:
> On 5/5/07, John Joyce <dangerwillrobinsondanger / gmail.com> wrote:
>> What I'd like to do is similar to the idea of processing files and
>> outputing results with names of files.
>> I want to do the same with objects.
>> I wrote an little code block just to talk back to me and tell me if
>> an object is tainted or not. ("I'm making it plain English sentences,
>> rather than simply true or false)
> [..]
> Variables are just names for objects, and aren't properties of the
> objects themselves.  Objects don't know what folks are calling them.

You can't go from an arbitrary object reference to an identifier, but
you can go from an identifier to an object reference via eval:

a = 42
@foo = 'bar'
["a", "@foo", "Array"].each { |id|
   puts "#{id} references a #{eval(id).class}"
}

# output

a references a Fixnum
@foo references a String
Array references a Class



Gary Wright