Yesterday17 / ZenScript

Visual Studio Code extension/Language Server for ZenScript, includes highlight, code snippet and language server(WIP). Works with 👇
https://github.com/Yesterday17/Probe
MIT License
34 stars 4 forks source link

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

Open ikexing-cn opened 2 years ago

ikexing-cn commented 2 years ago

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](https://github.com/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.