class sugar: static inheritance

Brendan Eich brendan at mozilla.com
Wed Jun 8 03:05:22 PDT 2011


On Jun 8, 2011, at 2:45 AM, Kam Kasravi wrote:

> Just as the private(this) is used to expose the private instance record,

Please read 

private(this), e.g., is
unbearably verbose;
leaks an implementation detail.
from http://wiki.ecmascript.org/doku.php?id=harmony:classes#open_issues.

The syntax is a placeholder. It will not last.


> could static([[Constructor]]) be introduced to provide access to the union of static properties across the set of constructor objects? (I know that their is some concern about the lengthy syntax of private())

It's not "concern", it is an open issue to resolve by using better syntax.

What does "union of static properties across the set of constructor objects" mean? We're not reifying sets of properties as objects, if that's what you mean (static private yikes).

I can see how private(foo) brings this to mind. This is the problem I clumsily labeled "leaks an implementation detail".


> Regarding the use of private(AssignmentExpression), does it provide access to all private ExportableDefinition's regardless of what inherited class they were declared in? That is given
> class Monster { 
>   constructor(health) { 
>     private health = health; 
>   }
> } 
> 
> class GilaMonster prototype Monster {
>   constructor(owner) { 
>     super(10); 
>     private owner = owner;
>   }
>   eat(critter) { 
>     If(critter === private(this).owner) {
>       private(this).health = 0; 
>     } else {
>       private(this).health++;
>     }
>   }
> }
> 
> Should the GilaMonster's private record include health?

The "private record" especially views as an "object" is a kind of placeholder too. It doesn't help to think of it as a record. It probably does not help to think of it as an object, either, especially if you cannot get at it via anything like the still-straw private(this) or private(other) syntax.

On another topic, it does seem like "protected" is inevitable, doesn't it?

/be

> 
> 
> On Jun 6, 2011, at 11:08 AM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
> 
>> 
>> On Jun 6, 2011, at 10:32 AM, Brendan Eich wrote:
>> 
>>> On Jun 6, 2011, at 10:19 AM, Bob Nystrom wrote:
>>> 
>>>> On Sun, Jun 5, 2011 at 9:35 PM, Peter Michaux <petermichaux at gmail.com> wrote:
>>>> Based on my understanding of what the desugared code would be, the
>>>> last line above would be an error because Dragon.allMonsters is
>>>> undefined.
>>>> 
>>>> That's correct. Do you have any examples of code where inheriting the constructor objects would be helpful?
>>> 
>>> Used all the time in Ruby, and in some Smalltalks. Supported by CoffeeScript. See
>> 
>> Actually, all modern Smalltalks where modern means anything post 1980
>> 
>> 
>> 
>> 
>>> 
>>> https://gist.github.com/1007150
>>> https://gist.github.com/1006999
>>> 
>>> (warning: Ruby reading skills required).
>>> 
>>> /be
>>> 
>>> _______________________________________________
>>> es-discuss mailing list
>>> es-discuss at mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>> 
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110608/22388ddf/attachment.html>


More information about the es-discuss mailing list