class sugar: static inheritance

Kam Kasravi kamkasravi at yahoo.com
Wed Jun 8 02:45:48 PDT 2011


Just as the private(this) is used to expose the private instance record, 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())

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?


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/9b593177/attachment.html>


More information about the es-discuss mailing list