Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement Request] Parsing of request to add function default arguments #48

Open
ikexing-cn opened this issue Nov 3, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@ikexing-cn
Copy link

Since CraftTweaker 4.1.20.668, ZenScript supports default arguments
This means that you can do:

function foo(a as int, b as int = 2, c as int = 3) as void {
    print(a + b + c);
}

foo(1); // print 6 [1 + 2 (default) + 3 (default)]
foo(1, 3); // print 7 [1 + 3 + 3 (default)]
foo(1, 1, 4); // print 6 [1 + 1 + 4]

Note 1: You can use bracket handlers and functions for default arguments. But variables are not allowed. Currently, they areseen as strings, but may produce parse exception in the future version.
Note 2: Once a parameter have a default argument, the parameters after it also require a default argument.

—— From friendlyhj

As yet, there is no corresponding syntax parsing for this function, and it is hoped that it will be added in the new version.

@Yesterday17 Yesterday17 self-assigned this Nov 4, 2021
@Yesterday17 Yesterday17 added the enhancement New feature or request label Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants