Let's not bikeshed class private syntax just yet. I mean, we could
(es-discuss, right?) but I don't think it is productive.
And again, we do not want a reified "private state object", so private
could not be a free expression. This also hurts private(other).weight --
'weight' is not an identifier in a "private state object", it has to be
a private name object binding. Therefore we should avoid any syntax
suggesting a first-class reflection of a private state object.
This is why @foo for private name object bound to lexical identifier foo
has been proposed. It also has the benefits of being shorter and
matching some other languages near to JS.
/be
Herby Vojčík <mailto:[email protected]>
January 19, 2012 9:58 AM
Hello,
I think private itself could be used as a shortcut to private(this).
It may look for example like this:
class Foo {
...
leq(other) {
return private.weight <= private(other).weight;
}
...
}
It is not unprecedented, there already is a keyword that represents
this as well as other object in a strange manner (super). So private
can also be such a word.
I don't see any grammatical/parsing/syntanctic problems with this for
the moment. Maybe you find one.
Herby
P.S.: Since it is very similar (and private.foo works everywhere, not
only in constructor), it may be though of to remove 'private foo =
bar;' in constructor in favour of 'private.foo = bar;'. But it is only
sort of afterthought. Also, 'public baz = moo;' could then be changed
by simple 'this.baz = moo;' to make code in constructor more akin to
code used everywhere else.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss