SV: self_parent

I would worry about obstructing the GC.

-----Oprindelig meddelelse-----

Fra: Tom Sawyer []
Sendt: to 04-07-2002 19:20
Til: ruby-talk ML
Emne: self_parent

i was wondering what others thought of the idea of having a built in
reference to the creation-parent for every object? much like the built
in self reference which points to the object, self_parent would point to
the object in which self was created. for example:

class S
  def initialize

class P
  def initialize
    @s =
  def hello
    p "hello world"

p =   -->   hello world

in my experience, i have encounter numerous places where i'd like access
to the parent object, in these cases i've had to pass the parent's self
to the child on instatiation. i.e. @s =, and store that
within an instance variable of the child.

since it's only a reference, i would think there would be little
overhead to keeping this reference available automatically. in fact, i
imagine the information is already there, just without a way to get to
it. i think numerous programs could make use of such a feature.

what'ya think?


"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety."
                                       -- Benjamin Franklin