Value objects: roll your own?

Brendan Eich brendan at mozilla.com
Sun Jan 12 18:18:34 PST 2014


Axel Rauschmayer wrote:
> Nice! Should the operator (case) definitions really be inside the 
> class? E.g., conceptually, number + point2d does not belong to a 
> single class, it belongs to both.

Or to neither. Still there's an advantage in using the class as the 
locus of multimethod definitions: all combinations point2d defines with 
other types, in particular with number, go in value class point2d. 
Another advantage: unary operators do belong here.

> Or, possibly:
>
> ```
>     function + (a :: number, b :: point2d) {
>         return point2d(a + b.x, a + b.y);
>     }
> ```

Nope, guard syntax is losing to bind, and we don't want guards here anyway.

/be


More information about the es-discuss mailing list