shortcut for private(this)

Herby Vojčík herby at mailbox.sk
Thu Jan 19 09:58:56 PST 2012


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.


More information about the es-discuss mailing list