Skip to content

Classes

Vihan edited this page Dec 11, 2018 · 2 revisions

In VSL a class represents a type. A group of variables (specifying 'state') and methods to modify that state. VSL's class and inheritance system is Object-Oriented with a few of VSL's own behaviors.

Declaring a class

A class is declared using:

class MyClass {
    // Class body
}

Access modifiers

You can prepend the following modifiers to your class statement to modify access:

Access Modifier Same File Same Module Different Module
public Yes Yes Yes
none Yes Yes No
private Yes No No

Internal Structure

VSL specifies that the fields of a class will be generated in-order. This minimizes overhead and allows for easier ABI compatibilities however in cases of dynamic dispatch, certain fields may be appended to quicken dynamic dispatch. The only item that may be prefixed is the V-table. If you which to be sure about the internal ABI specify the @dynamic attribute. See more about this in the attributes section