Skip to content

[BUGFIX/FEATURE] Wildcard Function Binds - #532

Merged
AbnormalPoof merged 1 commit into
FunkinCrew:developfrom
nykwono:fix-wildcard-binds
Oct 5, 2026
Merged

AbnormalPoof merged 1 commit into
FunkinCrew:developfrom
nykwono:fix-wildcard-binds

Conversation

@nykwono

@nykwono nykwono commented Oct 5, 2026

Copy link
Copy Markdown

Fixes #327

This PR adds support for wildcards to be used when using the bind() function.

How it works

When using _, normally it throws an error as _ isn't a variable, to circumvent it, it simply checks if we're inside a bind function and notes that this is a wildcard.
Later, when the bind function is actually called, the arguments are then evaluated to account for any wildcards and replaces them with the necessary value.

override public function onCreate(event:ScriptEvent)
{
  var map = new IntMap();
  var f = map.set.bind(_, "12");

  f(1);
  f(2);
  f(3);
  trace(map.get(1)); // 12
  trace(map.get(2)); // 12
  trace(map.get(3)); // 12
}
hscriptClass(assets/ui/TestScript.hxc):19: 12
hscriptClass(assets/ui/TestScript.hxc):20: 12
hscriptClass(assets/ui/TestScript.hxc):21: 12

@AbnormalPoof
AbnormalPoof merged commit 18d29c9 into FunkinCrew:develop Oct 5, 2026
9 checks passed
@nykwono
nykwono deleted the fix-wildcard-binds branch October 5, 2026 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants