final struct ?

wjoe invalid at example.com
Tue May 19 10:01:34 UTC 2020


As I was reading a few source files of a library I found dozens 
of final struct declarations like this:

final struct Foo {

   const pure final nothrow bar() { ... }

}

What's this supposed to express ?

A final class is a class that can't be subclassed - structs can't 
be subclassed, so does that express something else or is the 
final redundant ?
Additionally since it's not possible to subclass a struct it's 
also not possible to override bar() - does 'final bar()' mean 
something else ?

The only relevant bits of my web search for 'dlang: final' were 
results for final class, virtual functions and final switch. Am I 
missing something ?


More information about the Digitalmars-d-learn mailing list