Axel Rauschmayer (2013-07-28T23:08:05.000Z)
domenic at domenicdenicola.com (2013-08-12T05:17:49.242Z)
1. Absolutely love the multiple dispatch stuff (slide 10). 2. A bit uneasy about typeof, which will never properly express JavaScript’s “class” hierarchy. That is bound to always confuse people (already: “wait – I thought a function was an object”, worse with value objects). But maybe it’s the best we can do. Being able to fix typeof null is awesome, though. 3. Also love that we’ll get 64 bit integers etc. (slide 11) and user-definable value objects. W.r.t. to #1: Couldn’t we extend that to universal multiple dispatch? ```js const removeAll = new MultiMethod(); // not a realistic example removeAll.addMethod(Array, Set, (arr, set) => { ... }); removeAll.addMethod(Object, Map, (obj, map) => { ... }); ``` For the plus operator: ```js import { operatorPlus } from '@operators'; operatorPlus.addMethod(Point, Number, (a, b) => Point(a.x + b, a.y + b); operatorPlus.addMethod(Number, Point, (a, b) => Point(a + b.x, a + b.y); operatorPlus.addMethod(Point, Point, (a, b) => Point(a.x + b.x, a.y + b.y); ``` In my experience, multiple dispatch and single dispatch are highly complementary. Reenskaug and Coplien seem to have come to a similar conclusion (well, at least I would combine single dispatch and multiple dispatch to implement the DCI ideas): http://www.artima.com/articles/dci_vision.html