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
The trick used by parameter-freedom proposal is cute: to stop infestation of the code with "child" and "children" boilerplate, turn these parameters into positional ones.
However, the idea creates some new problems that better be avoided.
it's difficult to visually identify positional parameters - they lack visual cues
backwards compatibility is broken
proposal extends the syntax much further than we can justify based on known use cases
Suggested solution:
to avoid intermixing positional and named parameters, let's introduce a new type of parameter. Let's tentatively call it 'trailing parameter'.
Trailing parameter can be single-valued (like child) or vararg (like children)
Only one trailing parameter! (vararg counts as one)
trailing parameter can be passed as name:value pair, like a named one (e.g. child: value or children:[value, value,...]) - in any position, or without name, as a last parameter in the parameter list. This keeps the design backwards-compatible.
support special marker (e.g. +) as (optional?) visually identifiable prefix for trailing parameter (in case of vararg, this applies to each value)
Note: this proposal doesn't apply to argument blocks. In argument blocks, positional parameters cannot be expressed without introducing new rules, which is beyond the scope here.
But because trailing parameter can function also as a named one, no new problems are created with respect to child/children.
The text was updated successfully, but these errors were encountered:
The trick used by parameter-freedom proposal is cute: to stop infestation of the code with "child" and "children" boilerplate, turn these parameters into positional ones.
However, the idea creates some new problems that better be avoided.
Suggested solution:
child: value
orchildren:[value, value,...])
- in any position, or without name, as a last parameter in the parameter list. This keeps the design backwards-compatible.Example:
Note: this proposal doesn't apply to argument blocks. In argument blocks, positional parameters cannot be expressed without introducing new rules, which is beyond the scope here.
But because trailing parameter can function also as a named one, no new problems are created with respect to child/children.
The text was updated successfully, but these errors were encountered: