Page MenuHomeFeedback Tracker

[Feature Request] Provide access to HashMapObject parent "class"
Closed, ResolvedPublic

Description

We can use some sort of inheritance with HashMapObject by using #base.

I propose a "magic" HashMapObject special value #parent; a HashMap with which to gain access to an object's parent's methods:

private _baseClass = [
    ["updateMap", { /* parent class update code */ }]
];

private _childClass = [
    ["#base", _baseClass],
    ["updateMap", {
        private _arguments = _this;
        private _allParentMethods = _self get "#parent"; // HashMap
        private _parentMethod = _allParentMethods get "updateMap"; // typeOf _parentMethod == "CODE"

        // Call `_baseClass::updateMap`
        _self call [_parentMethod, _arguments];

        /* class specific additional code to "updateMap" */
    }]
];

Details

Severity
Feature
Resolution
Won't Fix
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

gor3Splatter renamed this task from Provide access to HashMapObject parent "class" to [Feature Request] Provide access to HashMapObject parent "class".

I think some sort of preprocessor would be needed. I have created a mod which can be placed at top level (like CBA) and does 'extra' stuff to sqf files which return an array formatted for hashmap objects. Not announced yet but, I dont mind people poking around or using it themselves right now. https://github.com/XPS-Group/XPS_A3/tree/main It does already do what you are looking for.

dedmen added a subscriber: dedmen.EditedSep 26 2023, 2:13 PM

The bases actually don't exist as separate objects. They are all merged (and partially overwritten) when the object is created. So to link to them, we would also have to create instances of the base classes. I don't want to waste that memory/processing time.

Could add a flag for it, so you can opt in to that extra cost. But I don't want to do this.

dedmen closed this task as Resolved.Sep 26 2023, 2:14 PM
dedmen changed Resolution from Open to Won't Fix.

Alright, thanks for feedback. Will try what @crashdome suggested instead.