-
Notifications
You must be signed in to change notification settings - Fork 736
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
Named argument support #6969
Labels
Comments
Hi jeskew, this issue has been marked as stale because it was labeled as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. Thanks for contributing to bicep! 😄 🦾 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Is your feature request related to a problem? Please describe.
Based on a comment from the newline sensitivity issue:
When passing a number of arguments to a function, it can be unclear which argument corresponds to which parameter. Readability hurdles are compounded when all function arguments appear on the same line and/or when complex expressions are used for one or more arguments.
Due to line size concerns, this feature should not be implemented until newlines are allowed as syntax trivia in function expressions.
Describe the solution you'd like
Readability for long function expressions may be improved by allowing callers to label their arguments (i.e., something like C#'s named arguments or Python's keyword arguments). I expect that Bicep functions' frequent use of overloads and varargs would make this feature fairly complex to implement.
Strawman syntax
An initial implementation could be closely patterned on C#'s named arguments.
For a function with a fixed number of parameters, such as
endsWith
, named arguments would allow callers to provide arguments out of order. The following three expressions would be equivalent:Named arguments may improve readability when a less-often used optional parameter is supplied, e.g.:
Like in C#, named variable length arguments would need to be supplied as an array:
ARM JSON compiled from Bicep with named arguments would use unnamed, positional arguments in the correct order. No changes would be required in the ARM deployment engine.
The text was updated successfully, but these errors were encountered: