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]
https://mail.mozilla.org/listinfo/es-discuss
--
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