>> 2) The conventional JS pattern is to place methods on the prototype, not the 
>> instance, and many felt that the main thing classes need to provide is a 
>> syntax to make this traditional semantics easier to express.

>This is the big one.

Class syntax with class parameters instead of explicit constructors can still 
be defined to produce methods on the prototype, right?

Andreas' example:

  class Point(x, y) {
   public function abs() { return Math.sqrt(x*x, y*y) }
  }

Can effectively desguar to:

  function Point(x,y) {
    this.x = x; 
    this.y = y;
  }
  Point.prototype.abs = function() { return Math.sqrt(this.x*this.x, 
this.y*this.y); }

Or, with private names, to a variant with the captured x and y stored as 
private fields on the instance.  It's really just a syntax choice between 
explicit constructor functions and parameterized class definitions.  There are 
many benefits to the latter, and many modern OO languages seem to be using this 
style effectively.  

Luke

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to