Patterns with virtual types as a means to avoid "type casts"

Problem statement

The reason for the necessity of type casts in languages like C++ or Java is

  1. that you cannot replace the types of all kinds of variables (local variables, member variables, function parameters) with more derived types on class derivation and
  2. that you cannot consistently specialize entire groups of interdependent classes.

(Eiffel supports redefinitions of the first category but either requires very complicated and expensive "system-level type checks" at compile time or must rely on run time type checks.)

The pattern / virtual type concept of Lava with its modified, VT-related type conformance checks fulfills both requirements and provides a type-safe and consistent way of specializing entire groups of interdependent classes. It particularly enables specialization of local variables, member variables, and function parameters without requiring the exhaustive system-level type checks of Eiffel and without having to rely on run time type checks to this end.

Pattern samples