Classes

Classes are the primary building blocks of Ozark applications. With the exception of enumerations, a class is the only thing that exists outside of any other context. Building an Ozark application consists entirely of building classes and enumerations.

Classes correspond to single files within an operating system. Class file names end with .class.en.ozark, with ".ozark" being the technical file extension, ".class" being an identifier that Ozark uses to differentiate between classes and enumerations, and ".en" being the language identifier as described by Ozark's localization system.

A class is a compound data type. An instance of a class is called an object and that object can be referenced by a pointer.

A class may contain any number of the following declarations in this order:

  • inheritance - A parent class from which this class inherits all properties and methods
  • type - If this class uses generics, a placeholder for a type that is specified on object initialization
  • property - A pointer or collection within the scope of the object of this class
  • method - A named subroutine with any number of inputs and outputs
  • extension - A method that extends another from itself or from an inheritance
  • replacement - A method that replaces another from itself or from an inheritance

A class starts with a capital letter, and everything is declarative within a class definition. Only a method has imperative statements.

Superhero.class.en.ozark
inheritance Hero

property @superpower: Superpower
property @strength: Strength

extension setup
	create XRayVision; assign to @superpower; setup
	
	assign .fullStrength to @strength

Inheritance

Ozark classes can inherit properties and methods from other classes, called inheritances or superclasses.

Ozark supports multiple inheritance. For example, a Cat can be both a Cartoon and an Animal. Method naming conflicts arising from inheritance are not resolved; Instead, the methods are executed one after the other in reverse order in which they are declared. Method implementations are selected using dynamic dispatch at runtime.

Cat.class.en.ozark
inheritance Cartoon
inheritance Animal

property @whiskers: [Whisker]
property @tail: Tail

extension setup
	create [Whisker]; assign to @whiskers; setup | repeat 6 times
	create Tail; assign to @tail; setup

method catNap
	print "zzzzzzz"