Skip to content
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

Concise syntax for splatting args and kwargs #4

Closed
jariji opened this issue Aug 20, 2022 · 2 comments
Closed

Concise syntax for splatting args and kwargs #4

jariji opened this issue Aug 20, 2022 · 2 comments

Comments

@jariji
Copy link

jariji commented Aug 20, 2022

It would be nice to have a concise syntax for splatting args and kwargs.

What should g(ft...) do: should it splat the args and kwargs like this?

g(getfield(ft, :t)...; getfield(;ft, :nt)...)
@ararslan
Copy link
Owner

Since FrankenTuples iterate values in order and g(ft...) is splatting outside of a named context, I think the only thing that can be done is for g(ft...) to be equivalent to g(Tuple(ft)..., NamedTuple(ft)...) (note the lack of an intervening ;) which is currently the case. That is, all values become positional arguments. It would be nice to be able to do what you're suggesting but I don't think it's possible, nor would it be consistent with e.g. g(NamedTuple(ft)...).

ftcall serves this purpose though: ftcall(g, ft) will do what you want. We could introduce a macro that translates g(ft...) to a call to an internal function that will dispatch on whether the thing being splatted is a FrankenTuple and in that case call ftcall, otherwise just do the call as written. I'm not sure how generally useful that would be though. What do you think?

@jariji
Copy link
Author

jariji commented Aug 21, 2022

It would be nice to be able to do what you're suggesting but I don't think it's possible

That seems likely.

@jariji jariji closed this as completed Aug 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants