some sort of abstraction could use it and actually static in PHP is more
like this in JS so that was a wrong example.
I am just wondering if this super, if defined dynamically per each function
call that uses it, won't slow down things as arguments does.
I agree that cases may be few but just think about mixins and mixins
created through inheritance.
function Point(x, y) {
this.x = x;
this.y = y;
}
Point.prototype.isPositive = function () {
return -1 < this.x && -1 < this.y;
};
Point <| function 3DPoint(x, y, z) {
super(x, y);
this.z = z;
}
3DPoint.prototype.isPositive = function () {
return super() && -1 < this.z;
};
Now try to imagine many other object would like to implement the
3Dpoint#isPositive method using 3DPoint as interface but without
necessarily extending it .... blah, I know this example is crap so I will
think about a better one.
function Entity() {} // no point by default
Entity.prototype.setPoint = function (x, y, z) {
3DPoint.call(this, x, y, z);
this.hasPoint = true;
return this;
};
Entity.prototype._isPositive = 3DPoint.prototype.isPositive;
Entity.prototype.isPositive = function () {
return this.hasPoint && this._isPositive();
};
Entity.prototype.hasPoint = false;
(new Entity).setPoint(1, 2, 3).isPositive(); // boom ? or super is bound to
Point ?
br,
Andrea Giammarchi
On Sat, Oct 29, 2011 at 2:25 PM, Axel Rauschmayer <[email protected]> wrote:
>
> Summary: true generic |super| hardly ever makes sense. Do you have a
> concrete example where you need it?
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss