Skip to content

KirillBelovTest/Objects

Repository files navigation

Objects

Simple objects implementation

Instalation

PaletInstall["KirillBelov/Objects"]

Import

Get["KirillBelov`Objects`"]

Object

Instance of the Object:

object1 = Object[]

Object[]

New type

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