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

Splat #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Splat #52

wants to merge 3 commits into from

Conversation

ps-pat
Copy link

@ps-pat ps-pat commented Sep 10, 2023

Adds support for splatted functions. Specifically, implement the following parsing rules:

  • splat(f)(args...) --> f(firstargs..., args...);
  • splat(f)(args..., _) --> f(args, _...).

Of course, args... can be empty and there can be as many _ as desired.

@jkrumbiegel
Copy link
Owner

Hi, thank you for the PR!

Why do you think splat(f) plus special parsing rule is preferable to f(_...,)? It seems much shorter to me and doesn't add any complexity.

As splat(f) can be stored in a variable g, using g in the chain would then have different behavior which I don't really like.

@ps-pat
Copy link
Author

ps-pat commented Sep 11, 2023

Hi!

First of all thank you for your great package 😄

It is just a code pattern that I use a lot. I thought I would propose it as other people might like it but at the end of the day, it is a matter of personal preference. It just feels natural for 1-argument higher-order functions calls (like splat(f)) to be parsed that way but again, that's very personal.

As for your second point I agree with you. Maybe it would be better for consistency's sake to use a "macro" kinda like @aside to tag statements for special parsing?

Anyway, feel free to do whatever you think is best with this PR!

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

Successfully merging this pull request may close these issues.

None yet

2 participants