Class - Saskyc/Lunacity-Wiki GitHub Wiki
What is class?
Class is template to later be created as object, can hold fields, properties & methods.
Definition
accessor class Name:
end
Accessors
Public
- Can be called from anywhere, no restrictions.
public class Name:
end
Internal
- Can be accessed inside of module currently defined in and modules in same family.
- If defined in Sit then Sit.Adipiscing is allowed to use this method.
internal class Name:
end
Modulewide
- Can only be accessed inside of module currently defined in.
- If defined in Sit then Sit.Adipiscing is not allowed to use it, only definitions inside of module sit.
modulewide class Name:
end
Disallowed
- This class cannot be accessed from anywhere, but the runtime.
disallowed class Name:
end
Value storing
Fields
Definition:
- Lorem has field called Ipsum.
public class Lorem:
public Type Ipsum
end
Example:
public class Lorem:
public int Ipsum
[Constructor]
public static method creates Lorem Ctor(int ipsum):
self.Ipsum = ipsum
end
end
Properties
Definition:
public class Lorem:
public Type Dolor:
public method returns Type Get():
return null
end
public method Set(Type value):
end
end
end
Example:
- Creates Ipsum that can be accessed but only set when allocating Lorem with argument of int.
public class Lorem:
private int _ipsum
public int Ipsum:
public method returns int Get():
return _ipsum
end
disallowed method Set(int a): end
end
[Constructor]
public static method creates Lorem Ctor(int ipsum):
self._ipsum = ipsum
end
end
Inheritance
Other classes
Use the extends targetedClass
- class can extend only 1 class.
- Defaultly classes that do not extend anything extend the base class
Object
Definition:
public class DefiningClass extends TargetedClass:
end
Interface
Use the implementes targetedInterface
- Class can inherit any amount of interfaces.
- Seperate multiple interfaces by
,
public class DefiningClass implements ITargetedInterface, IAnotherTargetedInterface:
end
Mixxed
extends is prioritized before implements.
public class DefiningClass extends TargetedClass implements ITargetedInterface, IAnotherTargetedInterface:
end