-
Notifications
You must be signed in to change notification settings - Fork 512
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
Dispatching variadic arguments to dependencies with splats #558
Labels
Comments
latk
added a commit
to latk/just.rs
that referenced
this issue
Jan 11, 2025
In support of: * casey#2458 * casey#1988 A `Val` is a list of strings, but at each point of usage we must decide whether to view it as a singular joined string or as a list of its parts. Previously, Just values were single strings, so in most places we have to invoke `to_joined()` in order to maintain compatibility. In particular, recipes, functions, and operators like `+` or `/` operate solely on strings. This includes logical operators like `&&`, which continue to be defined on strings. That means, the values `[]` and `['']` are currently completely equivalent. So far, this is a purely internal change without externally visible effects. Only the `Bindings`/`Scope`/`Evaluator` had API changes. No new syntax is implemented. However, in expectation of expressions that build lists, a new `evaluate_list_expression() -> Vec<String>` method is introduced that could be used to implement splat or generator expressions. It is already referenced wherever we have lists of arguments, e.g. variadic functions like `shell()` and dependency arguments. But because singular expressions are equivalent to a joined string, this is an unobservable detail for now. For experimenting with lists of strings, variadic recipe parameters like `*args` now produce a multi-part Val, and default to an empty list (not a list with an empty string). Because all operators use `to_joined()`, this is an unobservable implementation detail. However, if any operator becomes list-aware, then this detail should be reverted, or moved behind an unstable setting. For better understanding of the current behavior, I added a bunch of tests. These will help detect regressions if functions or operators become list-aware. No existing tests had to be touched. Next steps: This change is just the foundation for other work, but some ideas are mutually exclusive. Relevant aspects: * list syntax in casey#2458 * list aware operators in casey#2458 * lossless forwarding of variadics: casey#1988 * invoking dependencies multiple times: casey#558 The preparatory work like `evaluate_list_expression()` is biased towards implementing a splat operator that would enable casey#2458 list syntax and casey#1988 list forwarding, but doesn't commit us to any particular design yet.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It should be possible, when a variadic parameter receives multiple arguments, to call a dependency for each of those arguments:
This could look like:
Which would have the effect of, for each value in
args
, callbar
with that value:The text was updated successfully, but these errors were encountered: