Inheritance and safe casts
tulam classes have single implementation inheritance, explicit overriding, and checked nominal subtyping.
Extending a class
class Dog(breed:String) extends Animal("unknown", 0) = {
override function describe(self:Self) : String = self.breed;
final function species(self:Self) : String = "Canis familiaris";
static function family() : String = "Canidae"
};The child declares only its own fields; inherited fields are laid out parent first. override is required when replacing a virtual parent method. final prevents further replacement.
Parent calls
super.describe()super invokes the parent implementation rather than performing dynamic selection on the receiver.
Upcasts
If Dog extends Animal, then Dog <: Animal. Passing a dog where an animal is expected elaborates an explicit upcast coercion. Dependent Pi results substitute the accepted coerced term, preserving type correctness.
Downcasts
downcast(Dog, animal) : Maybe(Dog)A downcast is checked and may fail, so it returns Maybe. as is never class downcasting; it is reserved for declared representation conversion.
Matching classes
Sealed hierarchies can participate in exhaustive matching. An open class hierarchy needs a fallback because another subclass may exist. Portable dispatch and downcasting use class identity/tag information even when a target maps the class to its native object model.
Foreign object models
Future interop providers may map ordinary class syntax to a foreign object model only after checking metadata and preserving construction, layout, virtual dispatch, nullability, and ownership contracts. There is no separate unchecked subclass language in the current surface reference.
Common mistakes
Mark an inherited replacement override, never use as for a downcast, and do not expect super to perform dynamic receiver dispatch. A failed downcast is ordinary Nothing, not unchecked memory reinterpretation.
Recap
Single inheritance creates a directed nominal subtype relation. Upcasts are checked coercions; downcasts remain explicit partial queries returning Maybe.
Normative details: Language Reference §12.3–12.6.