C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Flat Dynamic Polymorphism Library

From: Nikl Kelbon <kelbonage_at_[hidden]>
Date: Sat, 16 Jul 2022 20:11:55 +0500
Thank you for your answer, I will try to answer briefly the first questions
that have arisen
> What you're calling "flat dynamic polymorphism" is what is typically
referred to as "type erasure."
No, it's implemented with type erasure, but it's not a type erasure. I
called it flat dynamic polymorphism because interfaces collapse into a flat
"dynamic concept" that can be reduced to smaller requirements.
For example, a polymorphic pointer to a value which can A, B, C can be cast
to a polymorphic pointer to a value which can A, B, because it is valid by
definition.
Thus, from a large interface <A, B, C ....> we can isolate the subsets we
need, getting different "interfaces".

I have seen all the works you listed in this area, the best of them I
consider the boost TypeErasure,
But nevertheless, each of them has its drawbacks, in the field of
performance, usability and most importantly - none of them is standard, and
I believe that even in the standard library there are many places where
this would be applicable

What about examples, pdf presents some links to godbolt with full examples
and my version of dyno 'Drawable' here :
https://godbolt.org/z/8YxPncEqE
> What are Draw, Method2, and Method3? What is any_with? What can I do with
this type? How do I construct it? What are its members? What does its
storage look like? Can I customize operations?
This is described below in the text, unfortunately I do not have much
experience in compiling such documents and did not want to overwhelm with
unnecessary details immediately from the "motivation"

сб, 16 июл. 2022 г. в 19:38, Barry Revzin <barry.revzin_at_[hidden]>:

> What you're calling "flat dynamic polymorphism" is what is typically
> referred to as "type erasure." It would be better to stick with existing
> names for things rather than introducing new ones. And there is definitely
> no reason any of these things should be an initialism (FDP for Germans is a
> political party, DST for Americans is daylight savings time).
>
> I think it would help if you took a look at all the existing work around
> type erasure. There are many libraries that solve this problem. Some
> examples:
>
> - Boost.TypeErasure (
> https://www.boost.org/doc/libs/1_79_0/doc/html/boost_typeerasure.html)
> - Dyno (https://github.com/ldionne/dyno)
> - FB's Poly (
> https://github.com/facebook/folly/blob/main/folly/docs/Poly.md)
> - Adobe's Poly (https://stlab.adobe.com/group__poly__related.html)
> - Boost::extTE (https://github.com/boost-ext/te)
>
> I'm sure I'm missing several. There's also plenty of good talks on this
> subject - I'd recommend Louis Dionne's (
> https://www.youtube.com/watch?v=gVGtNFg4ay0) and Sy Brand's (
> https://www.youtube.com/watch?v=8c6BAQcYF_E). While Louis' more covers
> what we can do in libraries today, Sy's is more what we could do in
> libraries tomorrow.
>
> Lastly, the paper doesn't really do a good job of presenting the library
> facility. Dyno and Folly Poly's docs, for instance, both go through a
> complete example for Drawable. This paper just has a single alias
> declaration:
>
> using any_drawable = any with<Draw, Method2, Method3>;
>
> What are Draw, Method2, and Method3? What is any_with? What can I do with
> this type? How do I construct it? What are its members? What does its
> storage look like? Can I customize operations?
>
> Barry
>
> On Sat, Jul 16, 2022 at 8:03 AM Nikl Kelbon via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> The current tools for dynamic polymorphism in C++ are not expressive and
>> efficient enough, almost all uses of virtual functions in the standard
>> library are poorly extensible and pay for what we do not use. I would like
>> to offer my vision of solving these problems.
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
>

Received on 2022-07-16 15:12:08