What is the best way to program over "abstract" types in D?
Adam D. Ruppe
destructionator at gmail.com
Sat Nov 23 22:52:10 UTC 2019
On Saturday, 23 November 2019 at 16:38:30 UTC, Ola Fosheim
Grøstad wrote:
> Ok, thanks, that is worth exploring. Right now the objects I am
> looking at are pure values, so that might be a bit verbose
> though.
In many cases, you can just do
auto c = scoped!Class(args, to, ctor);
and it mostly works. The only time you need to explicitly mention
the interface line is when passing to a template by value (since
then it will try to copy the scoped instance and that is a
compile error).
So you can frequently do it less verbosely than I did there.
> I also guess LTO happens too late in the process to carry over
> information about whether virtuals have been specialised or not.
I don't know really. Maybe I used the wrong argument to ldc too
to enable it.
> Yes, I am starting with structs, because pure values ought to
> be easier on the optimizer. So one should be able to go to a
> fairly high abstraction level and still get good performance.
Yeah, just I expect classes will win overall :) We'll see, I
suppose.
More information about the Digitalmars-d-learn
mailing list