Object.prototype.link

Garrett Smith dhtmlkitchen at gmail.com
Sun Feb 22 09:37:25 PST 2009


On Sun, Feb 22, 2009 at 6:01 AM, David-Sarah Hopwood
<david.hopwood at industrial-designers.co.uk> wrote:
> David-Sarah Hopwood wrote:
>> memolus at googlemail.com wrote:
>>> I'd like to use link(obj, target).
>>>
>>> E.g.
>>> a = 10;
>>> link(b, a);
>>> a++;
>>> b++;
>>> print(b);
>>> // output: 12
>>
>> That would require a "catchall" mechanism, allowing accesses to
>> nonexistent properties of an object to be handled. It's quite likely
>> that such a mechanism will be added, I think, but there is currently
>> no detailed concrete proposal.
>
> Sorry, I misread your example; a catchall mechanism is not particularly
> relevant to it.
>
> What you've asked for above can be implemented in terms of "linking" of
> properties using getters/setters, in the case where the variables are in
> the global scope or in a scope introduced using 'with'. However, why on
> earth would you want this? It looks frightful.
>

I agree.

BTW Several implementations implement a String.prototype.link method.

('a').link('b');

=> "<a href="b">a</a>"

:-)

Garrett


More information about the Es-discuss mailing list