Inheritance

From triplescripts.org wiki

Triple scripts support inheritance in the form class A extends Base but the stance of triplescripts.org is overwhelmingly against deep class hierarchies. At most, inheritance should be limited to being two or three levels deep, and even then used sparingly. Inheritance should always be treated as a code smell. Beyond authorial discretion and matters of taste, there are practical limits that come into play with the use of inheritance.

When a class inherits from another class in the triple script dialect, in order to work on legacy runtimes, the compiler has to reorder the modules so that the base class's t-block appears earlier in the text than the t-block for the derived class. This does lead to a stylistic concern in itself, since the program has a (perhaps minor) local violation of the top-down principle, but from a technical perspective, it also complicates the compilation routines.

The top-down violation is the reason why it's prohibited for the module that is the "heart" of the program to inherit from another class. It's possible to work around the legacy issue by writing all classes (or just the base class) as constructor function declarations rather than actually using the class keyword, but this further complicates the compiler and we elect not to implement special detection for this kind of thing.

Remember that triple scripts are meant to make people's jobs easy.

Cookies help us deliver our services. By using our services, you agree to our use of cookies.