On Wed, May 12, 2010 at 3:28 PM, Seiji Sam Lee <[email protected]> wrote:
> But I want to suggest a new property (like "Holder" or "This") called
> "Owner", a reference to the object that own (in origin) the property.
>
> It could allow things like that:
>
> var echo=$out.puts
> echo("Hello!!");

No, it couldn't because when you copy $out.puts to echo you are
copying the function named puts and you are not copying any
information about the $out object. That function has no notion of a
parent/container/self object until it is called in the scope of a
given "this" object. That is, a function handle contains no metadata
which points back to its "original" owner (and that owner could change
over time). Consider:

$out = {x:1};
$in = {x:2};

function puts()
{
  print(this.x);
}
$out.puts = puts;
$in.puts = puts;
// is equivalent to:
$out.puts = $in.puts = puts;

in that last statement, which object "should" be the Owner? It's not
answerable for the generic case.

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to