Chain.jl icon indicating copy to clipboard operation
Chain.jl copied to clipboard

Splat

Open ps-pat opened this issue 2 years ago • 2 comments

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.

ps-pat avatar Sep 10 '23 17:09 ps-pat

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.

jkrumbiegel avatar Sep 11 '23 11:09 jkrumbiegel

Hi!

First of all thank you for your great package :smile:

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!

ps-pat avatar Sep 11 '23 15:09 ps-pat