Dynamic templated virtuals - I still often want them
Steven Schveighoffer
schveiguy at gmail.com
Thu Jul 23 16:06:03 UTC 2020
On 7/22/20 10:38 PM, Adam D. Ruppe wrote:
> But imagine if `serialize` actually got a virtual table entry, just like
> if it wasn't a template at all, but each child class automatically got
> an instance of it made for itself.
This is a great idea. Fits right in with D's philosophy of having the
compiler write code for you so you don't have to.
I can imagine some great uses for serialization.
The syntax is probably the trickiest part of this potential feature --
especially since templates are automatically final, and we have no
virtual keyword.
Potentially as well, you could specify overrides of the Base template in
a derived type if needed.
One other tricky thing is that the override functions must not vary the
parameter or return types (except for covariance).
-Steve
More information about the Digitalmars-d
mailing list