Search code examples
dfinal

What does the 'final' keyword mean?


On this documentation page of interfaces on dlang.org, it says interfaces must implement final methods. What are final methods? The keyword doesn't seem to be mentioned on any other page.

There is this page I found, but it seems to be a remain from the ancient D1.

Is a final function simply a function returning an immutable result? Does the keyword even still exist?


Solution

  • A final function is one that cannot be overridden in a child class (the opposite of a virtual function).

    All templates are final, so any template in an interface must have a function body or else you'll get a linker error.