Can the D compiler detect final and optimize?

Daniel Kozak kozzi11 at gmail.com
Fri Dec 25 19:29:26 UTC 2020


On Fri, Mar 13, 2020 at 5:15 PM Dennis via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Friday, 13 March 2020 at 15:08:34 UTC, IGotD- wrote:
> > Instead of having final as default, can't the compiler itself
> > infer when a class is implicitly final and do the optimizations
> > itself?
>
> The problem is that only at runtime are all the derived classes
> known, and by then the code is already compiled. I think the Java
> Virtual Machine can automatically elide virtual calls by virtue
> of being a JIT, but for D this would mean either telling the
> compiler 'assume all derived classes are present in the source
> files provided here' or doing fancy link-time optimization.
>

I believe LTO could do that in some cases
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20201225/b0f4c539/attachment.htm>


More information about the Digitalmars-d mailing list