Sexy Scripting Language Wiki
An s-expression scripting language for highly demanding video games
Status: Beta
Brought to you by:
theabstraction
Classes exist to implement interfaces, and for no other reason. As an implementation detail they
are considered private to the module in which they are defined and cannot be accessed outside
that module, and thus cannot be aliased in a namespace. C++ however, can still interrogate
the containing module to find the class definition.
Classes are defined in a manner similar to structures, only they specify what interfaces are implemented using the *implements* clause: (class <name> (implements <fully-qualified-interface-name1>) ... (implements <fully-qualified-interface-nameN>) (<type1><name1>) .... (<typeN><nameN>) .... ) Example: (interface Sys.Animals.IDog (Bark -> (Int32 age)(Int32 breed)) ) (class Dog (implements Sys.Animals.IDog) (Int32 age) (Int32 breed) (Bool isMale) )
When we specify that a class implements interfaces, we must define a method for each of those methods
declared in the interfaces definition. This is done with
(method <class>.<name> <inputs> -> <outputs>: body)
To use the field from the given class in the body, prefix with 'this.' as can be seen in the example:
Example:
(method Dog.Bark -> (Int32 age)(Int32 breed): (age = this.age) (breed = this.breed) )