On Friday, 20 September 2013 at 07:39:47 UTC, QAston wrote:
On Thursday, 19 September 2013 at 22:46:09 UTC, Andrei
Alexandrescu wrote:
On 9/19/13 3:18 PM, Szymon Gatner wrote:
I had similar thoughts when watching GoingNaive 2013:
http://bartoszmilewski.com/2013/09/19/edward-chands/
Nice piece.
I was more and more scared with every talk and now I am
valualizing my
polymorphic types a'la Sean Parent
That I think is sketchy advice.
Andrei
What Sean Parent does in his value semantics talk is basically
an interface adapter for a struct, wrapped in a struct
providing implicit conversions.
By using structs by default and adapting them to interfaces as
needed you get to have the smallest possible overhead on a
single function call - either no virtual dispatch or 1 virtual
dispatch. When writing adapters to interfaces you get 2 or more.
The other benefit is that approach is reducing dependencies you
need to know about when you use the wrapper type - the approach
would not work in D due to lack of argument dependent lookup so
you need to write the adapter type (for a particular type you
want to convert) yourself anyways. And I think it's better that
way.
In the end the whole thing is just adapter design pattern
applied to C++.
http://dpaste.dzfl.pl/811800a5