Skip to content

Common - Cleanup DEFAULT_PARAM, _this#1706

Merged
PabstMirror merged 5 commits intoCBATeam:masterfrom
BrettMayson:this_reassign
Nov 10, 2024
Merged

Common - Cleanup DEFAULT_PARAM, _this#1706
PabstMirror merged 5 commits intoCBATeam:masterfrom
BrettMayson:this_reassign

Conversation

@BrettMayson
Copy link
Copy Markdown
Contributor

@BrettMayson BrettMayson commented Oct 19, 2024

Ref BrettMayson/HEMTT#804

When merged this pull request will:

  • Don't use DEFAULT_PARAM
  • Use different variables for _this
  • Rename the test for DEFAULT_PARAM to prevent HEMTT from yelling about it

@PabstMirror PabstMirror added this to the 3.18.2 milestone Oct 19, 2024
@BrettMayson BrettMayson changed the title don't use DEFAULT_PARAM, use different name for _this Common - Cleanup DEFAULT_PARAM, _this Oct 19, 2024
@PabstMirror
Copy link
Copy Markdown
Contributor

from discord

commy2 — 10/19/2024 7:16 AM
In general, using _this has the benefit that it is shadowed inside the called function, whereas introducing a local variable makes it bleed into the new scope.
There is a reason why _this is used. I don't like this part of the PR (no pun intended).
e.g, there is a reason it's named _CBA_code and not just _code.

I'm not worried about most of these changes, except for xeh and direct call.
A counter example I can come up with is

[] spawn {
    private _args = ["A"]; // user code
    sleep 0.1;
    [{  
        _args pushBack 77;
    }, _this] call CBA_fnc_directCall;
    x3 = _args; // just ["A"], expecting ["A",77]
};

changing to _CBA_args seems to fix

@PabstMirror PabstMirror merged commit f592bff into CBATeam:master Nov 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants