I'm a C++ programmer, and I'm curious, is it possible to create an abstract object with DM. I'd like to make a parent object that when created, somewhere else in the code it can become one of it's children, without having to define exactly what child it is.
For instance;
obj/A
var foo
obj/A/B
foo = bar
obj/A/C
foo = rab
something/s
obj/A/x = new Obj/A/C()
I'd like to be able to define Obj/A/x but if the code needs x to become Obj/A/C it can become said object. Apologies if I'm being incredibly vague, I'm not the best at describing the question.
ID:2301354
![]() Oct 3 2017, 10:56 am
|
|
That doesn't mean you have to totally give up on the idea, though.
DM allows runtime accesses rather than compile time accesses. You can use the ":" operator to invoke methods and access members of an object.
The above will fail to compile because /atom/movable is the root type of /obj and /mob, and o is cast as a movable atom. movable atom doesn't have the proc HerpyDerp.
You can get around this by using the ":" operator.
The above will compile. That's because ":" doesn't have to know which method it's going to invoke until runtime. "." has to be able to resolve it at compile-time.
Using ":" you can basically just redefine behavior all over your code and pretend you are using abstract classes or interfaces.