2011/1/10 Jürg Lehni <[email protected]>: > The mention of the term made me wonder: Is it wrong to dream of JavaScript > with operator overloading?
https://mail.mozilla.org/pipermail/es-discuss/2009-October/010068.html discusses it a bit and links to other discussions. > I have implemented it in Rhino's interpreter mode, and am using it in > Scriptographer.org to be able to write much nicer code to deal with 2d vector > arithmetics, and the benefits of that have been huge when using the platform > for teaching programming to visually thinking students, as it happened over > the past two years at the ECAL graphic design department in Lausanne, > Switzerland. > > E.g.: > > var middle = (point1 + point2) / 2; > var vector = point2 - point1; > > var point = middle + vector.rotate(90); > > Instead of: > > var middle = point1.add(point2).divide(2); > var vector = point2.subtract(point1); > var point = middle.add(vector.rotate(90)); > > etc. > > For those curious, here the repository with my Rhino modifications: > > https://github.com/lehni/rhino/tree/operator-overloading > > Best, > > Jürg > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

