intersystems cache - Does object script supports multiple inheritance? -
i new cache , found different normal oop concept. in object script base class can inherited multiple subclasses(inheritance order can left/right). if objectscript oop, don't know how cache supports this(unlikely other programming language).
baseclass
class inheritance.thebaseclass extends (%registeredobject, inheritance.thechildclass, inheritance.thechildclass1) [ inheritance = left ] { classmethod init() { //do ##class(inheritance.thechildclass).ping() //do ##class(inheritance.thechildclass1).ping() ..ping() ..pingggg() } }
child class 1
class inheritance.thechildclass extends %registeredobject { classmethod ping() { write "i in inheritance.thechildclass",! } }
child class 2
class inheritance.thechildclass1 extends %registeredobject { classmethod ping() { write "i in inheritance.thechildclass1",! } classmethod pingggg() { write "i in inheritance.thechildclass1111111111",! } }
output
i in inheritance.thechildclass
i in inheritance.thechildclass1111111111
documentation explains clearly: http://docs.intersystems.com/latest/csp/docbook/docbook.ui.page.cls?key=gobj_classes#gobj_classes_inheritance
for example, if class x inherits classes a, b, , c, definition includes:
class x extends (a, b, c) { }
the default inheritance order class compiler left right, means differences in member definitions among superclasses resolved in favor of leftmost superclass (in case, superseding b , c, , b superseding c.)
specifically, class x, values of class parameter values, properties, , methods inherited class (the first superclass listed), class b, and, finally, class c. x inherits class members b has not defined, , class members c neither nor b has defined. if class b has class member same name member inherited a, x uses value a; similarly, if c has member same name 1 inherited either or b, order of precedence a, b, c.
Comments
Post a Comment