www.digitalmars.com         C & C++   DMDScript  

D - Consider sealed modules

It may be useful to seal a module by declaring it final.

final module <name>;

What does it mean to seal a module? It would be equivalent to declaring all
leaf-level classes in the module final. In other words, a mechanism to
prevent intermodule inheritance of classes. Note that the "sealing" applies
only to classes (stateful) entities, not to interfaces.

The component software people write a lot about the problems associated with
inheritance of implementation (state) in large software systems, and I have
found this to be true in some of the code I've written. But I still think it
very useful in smaller systems, and doing away with it, as Heron does, or as
James Gosling has said he ought to have in Java, is a bit too radical IMHO.

With the possibility of sealing a module, we could easily control
intermodule inheritance relationships.

Matthias
Feb 22 2004