Simple objects implementation
PaletInstall["KirillBelov/Objects"]
Get["KirillBelov`Objects`"]
Instance of the Object
:
object1 = Object[]
Let's create a type with default parent type (Object), constructor (Identity) and fields ({}):
CreateType[Human]
Human
New type inherited from Human:
CreateType[Student, Human]
And with special constructor
Student /: IdentifyFaculty[student_Student] := student["Faculty"] = "Math"
CreateType[MathStudent, Student, IdentifyFaculty]
MathStudent
And with custom fields:
CreateType[PhDStudent, MathStudent, IdentifyFaculty, {Advisor, "ScientificWork", Articles -> {}}]
PhDStudent