Giter Site home page Giter Site logo

Comments (15)

wyaeld avatar wyaeld commented on May 4, 2024

I tend to agree that indenting implies a connection and is easier to eyeball

from elixir_style_guide.

Gazler avatar Gazler commented on May 4, 2024

Just quoting the relevant part as it currently stands for ease:

# Multiline pipelines use a single level of indentation.
some_string
|> String.downcase
|> String.strip

# Multiline pipelines on the right side of a pattern match
# should be indented on a newline
sanitized_string =
  some_string
  |> String.downcase
  |> String.strip

How would this proposal looks with binding as it stands? Should it stay the same or be one of the following?

sanitized_string = 
  some_string
    |> String.downcase
    |> String.strip

Or

sanitized_string = some_string
  |> String.downcase
  |> String.strip

Personally I disagree with the proposal - I think the pipeline operator provides sufficient relationship to the line above.

from elixir_style_guide.

chrismccord avatar chrismccord commented on May 4, 2024

You can and should be free to write code exactly how you've laid out. But if we must bikeshed, I Iike mine blue. Here's why: the current standard that multiline pipelines use a single level of indentation is preferred because the |> already denotes visual indentation to my eye.

from elixir_style_guide.

bcardarella avatar bcardarella commented on May 4, 2024

@Gazler I've written bindings in the 2nd form

from elixir_style_guide.

alxndr avatar alxndr commented on May 4, 2024

Agree with @chrismccord โ€” the |> serves as indentation to my eyes.

from elixir_style_guide.

bcardarella avatar bcardarella commented on May 4, 2024

@chrismccord @alxndr that's an interesting way to think about it, one I hadn't considered

from elixir_style_guide.

whatyouhide avatar whatyouhide commented on May 4, 2024

Came here to write exactly what @chrismccord wrote. Think about how IEx visually shows stuff when that stuff is part of a single expression:

iex> 1 +
...> 2

Showing the different prompt (...>) at the beginning of the line makes it clear that that expression is unfinished. I see a leading |> as an "unfinished expression" prompt.

from elixir_style_guide.

knewter avatar knewter commented on May 4, 2024

from elixir_style_guide.

nessamurmur avatar nessamurmur commented on May 4, 2024

Since this has been debated a couple times before and a lot of people seem to come out on the side of seeing |> as indention, anyone have any objections to closing this? (Will give a day or so for people to respond)

from elixir_style_guide.

adamkittelson avatar adamkittelson commented on May 4, 2024

Hopping on the no-need-to-indent bandwagon.

However I do tend to do:

some_var = some_value
           |> transformed
           |> by
           |> some
           |> pipes

rather than:

some_var = 
  some_value
  |> transformed
  |> by
  |> some
  |> pipes

from elixir_style_guide.

whatyouhide avatar whatyouhide commented on May 4, 2024

@adamkittelson this was discussed at length in #33 and the second version was pretty much a consensus.

from elixir_style_guide.

asaaki avatar asaaki commented on May 4, 2024

Regarding the "the pipe operator acts as indentation already":
I guess it depends sometimes more on the used color scheme for the syntax highlighting. In some of them the operator is even more outstanding (sometimes more than the following code), so it doesn't help to see an indentation at all. (Like seen above in the GH snippets.)
Without any colors it is equal to all typed stuff and the eye can't jump again, too.
So, please, don't be so quick stating it as a kind of fact; some people see differently than you do.

But in the end I just agree with @chrismccord 's first part of his answer:

You can and should be free to write code exactly how you've laid out.

from elixir_style_guide.

adamkittelson avatar adamkittelson commented on May 4, 2024

@whatyouhide I don't mind it if the variable name is long, or if i'm deeply nested or otherwise edging toward the right margin, but I think it looks silly do do it that way if you've got the space to do it the other way.

I guess in other words I like Jose's wording in that thread "If the right side of = goes too far (either because the left side is long or the right one is), I break it into another line"

If it's too long do it that way, but if I'm not space constrained I'm going to default to not having the hanging =

from elixir_style_guide.

ericmj avatar ericmj commented on May 4, 2024

One more vote for single level of indentation. The |> already provides enough guideline.

from elixir_style_guide.

likethesky avatar likethesky commented on May 4, 2024

@niftyn8 I think they've had a day (or 112!) to respond, so I vote to finally close this. For the record, I'm in agreement with most here that the first unindented |> does provide a visual clue that it's connected to the (initial) expression above it, even though in general I tend to prefer more whitespace.

Btw, |> is the pipe operator not the pipeline operator. However, once used, a pipe operator in combination with the operands does seem to constitute a pipeline. :bowtie: At least, that's the usage I see in the docs. Hence, "a multiline pipeline, or multiline pipelines" would be correct, but we "use many pipe operators in a multiline (or single line, for that matter) pipeline." However, I suspect my pedantry fights a losing battle over this distinction!

from elixir_style_guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.