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

Thread on single line with single-argument functions #206

Open
MicahElliott opened this issue Feb 25, 2020 · 3 comments
Open

Thread on single line with single-argument functions #206

MicahElliott opened this issue Feb 25, 2020 · 3 comments

Comments

@MicahElliott
Copy link

When threading a few calls single-argument calls that will fit within 80 characters, prefer a single line.

;; good
(-> x fizz :foo first frob)

;; not as good
(-> x
    fizz
    :foo
    first
    frob)

But when one of more functions takes arguments, split each call onto a separate line.

;; good
(-> x
    (fizz a b)
    :foo
    first
    (frob x y))

;; not as good
(-> x (fizz a b) :foo first (frob x y))
@bbatsov
Copy link
Owner

bbatsov commented Feb 26, 2020

I agree with the general premise, although I guess that's a bit subjective. Still, I wouldn't mind if we mention those suggestions in the guide.

@danielcompton
Copy link
Collaborator

danielcompton commented Mar 31, 2020

This seems subjective to me and hard to make a recommendation for when to use one or the other.

Often I find that I'll split a threading macro onto multiple lines if I want to really emphasis what is happening. Other times I'll leave it on a single line if it's a trivial transformation, even if there is a functional call with arguments.

@bbatsov
Copy link
Owner

bbatsov commented Dec 10, 2020

Same here.

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

3 participants