Even if GetBase was existing I don't know if it would cover all your
needs but unless I missed something I don't get your last example (where
p is defined and where GetBase is supposed to be called ?)
Le 06/03/2012 16:33, 程劭非 a écrit :
> Sorry.
> I mean the following case:
>
> var x = {
> a:{
> },
> b:{
> }
> }
>
> x.a.p = x.b.p = {};
>
> So GetBase is not able to decide to return x.a or x.b.
>
>
> 在 2012年3月6日 下午11:08,Aymeric Vitte <[email protected]
> <mailto:[email protected]>>写 道:
>
>> Some object could have more than one ancestor.
>
> Yes, so ? It's not in contradiction with what I am saying
>
> Le 06/03/2012 14:58, 程劭非 a écrit :
>> I prefer "this" to be root object. Some object could have more
>> than one ancestor.
>>
>> 2012/3/6 Aymeric Vitte <[email protected]
>> <mailto:[email protected]>>
>>
>> Yes, assuming that GetBase is usable (8.9) :
>>
>> var obj = {
>> x:{
>> a: GetBase(this) // obj
>> }
>> }
>>
>> But it is an internal function only, there are things defined
>> in specs to access properties of objects but nothing the
>> other way, because I believe the case never happens today.
>>
>> The "this" proposal is not bad for me (and even good), if I
>> take Lasse Reichstein's objection, I would say :
>>
>> {"a" : this.b, //undefined
>> "b" : this.a } //undefined
>>
>>
>> Same as if you do : function f() {this.a = this.b; this.b =
>> this.a}; var g = new f();//g.a undefined //g.b undefined
>>
>> It does not solve your issue but it makes me think to a more
>> global issue, the "lexical this" here
>> http://brendaneich.com/2011/01/harmony-of-my-dreams/ or this
>> post
>>
>> https://mail.mozilla.org/pipermail/es-discuss/2012-February/020749.html
>> (which apparently did not passionate)
>>
>> But this should not be applicable to functions only, this
>> could be generalized to objects, where "this" unless
>> explicitely bound to something should refer to the object
>> itself, and not the global object (moreover that there are
>> discussions about the future of the global object)
>>
>> Then an Object.GetBase could be added to refer to the
>> "parent" or "outer object"
>>
>> I am not aware of all discussions (maybe it was already
>> discussed and rejected) and it's not easy to see the whole
>> impact of such change, but I don't think that the idea is
>> absurd, I did not invent it myself and it would be more
>> logical than the current behavior of "this" and avoid
>> repetitives operations (var self=this, getters/setters, use
>> of new (why do I have to use new in the example above ?))
>>
>> Regards
>>
>> A. Vitte
>>
>> Le 05/03/2012 13:16, 程劭非 a écrit :
>>> {
>>> "a":123,
>>> "b": this.a
>>> }
>>>
>>> If you simply want “this” in JSON.parse, it will not be hard
>>> to implement it in my library.
>>> But I guess the problem is we have no way to refer to its
>>> parent. Do you have any ideas?
>>>
>>> 2012/3/5 gaz Heyes <[email protected]
>>> <mailto:[email protected]>>
>>>
>>> It's a shame that "this" doesn't work with object
>>> literals :(
>>> How nice would this be:
>>>
>>> {
>>> "a":123,
>>> "b": this.a
>>> }
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> [email protected] <mailto:[email protected]>
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> es-discuss mailing list
>>> [email protected] <mailto:[email protected]>
>>> https://mail.mozilla.org/listinfo/es-discuss
>>
>> --
>> jCore
>> Email : [email protected] <mailto:[email protected]>
>> Web : www.jcore.fr <http://www.jcore.fr>
>> Webble : www.webble.it <http://www.webble.it>
>> Extract Widget Mobile : www.extractwidget.com
>> <http://www.extractwidget.com>
>> BlimpMe! : www.blimpme.com <http://www.blimpme.com>
>>
>>
>
> --
> jCore
> Email : [email protected] <mailto:[email protected]>
> Web : www.jcore.fr <http://www.jcore.fr>
> Webble : www.webble.it <http://www.webble.it>
> Extract Widget Mobile : www.extractwidget.com
> <http://www.extractwidget.com>
> BlimpMe! : www.blimpme.com <http://www.blimpme.com>
>
>
--
jCore
Email : [email protected]
Web : www.jcore.fr
Webble : www.webble.it
Extract Widget Mobile : www.extractwidget.com
BlimpMe! : www.blimpme.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss