Skip to content

Inheritance

Vihan edited this page Nov 25, 2018 · 1 revision

Inheritance is the idea that one type can do all that another can and even more. To learn more about Object-Oriented Programming a tutorial will probably be better as this page specifies some of the inheritance behaviors specific to VSL.

Root Class

Most programming languages have a 'root class' from which all others inherit, for example, Java's Object. VSL also has a 'hidden' root class named Object. All types technically inherit from Object however the 'Object' contains no fields nor any methods. Object only exists for semantic purposes, it does not result in any overhead on your classes however it does allow you to cast all objects to this type.

That said, casts to Object must be explicit.

Internal specification

Casts to object look like:

struct vsl.Object {
    void* metatype;
    void* value;
}