Value objects: roll your own?

Andrea Giammarchi andrea.giammarchi at gmail.com
Sun Jan 12 22:11:07 PST 2014


what I meant is that you require('point3d') before requiring point2d .. is
that a concern? Is that like the point4d coming along unexpectedly?

Thanks


On Sun, Jan 12, 2014 at 10:04 PM, Brendan Eich <brendan at mozilla.com> wrote:

> Andrea Giammarchi wrote:
>
>> "the call is ambiguous and an error is thrown" .. that's OK, but this is
>> assuming you know upfront all libraries in the game, right?
>>
>
> No, this is just a matter of loading point2d's value class declaration,
> then point3d's.
>
> It's fine to have methods defined for various combinations, but defining
> them twice, with different bodies even (different dynamic return types), is
> an error.
>
>
>  Now, how about modules? Would this approach cause unknown possible
>> conflicts all over?
>>
>
> It doesn't matter whether you put the value classes in modules or at top
> level.
>
>
>  I understand the Python approach might not solve this neither,
>>
>
> Double dispatch doesn't solve anything here, it requires writing
> point2d.add and point2d.radd as well as the same for point3d, and
> typecase'ing in all four on the other argument's runtime type. And then
> you're stuck sending a PR, when point4d comes along.
>
> /be
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140112/ca5eafeb/attachment-0001.html>


More information about the es-discuss mailing list