You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Arguments MAY be prefixed with optional label of the parameter name to which the argument corresponds.
All unnamed arguments MUST precede named arguments in the function expression.
Named arguments MAY be provided in any order.
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:
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:
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! 😄 🦾
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: