Comments (15)
I tend to agree that indenting implies a connection and is easier to eyeball
from elixir_style_guide.
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.
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.
@Gazler I've written bindings in the 2nd form
from elixir_style_guide.
Agree with @chrismccord โ the |>
serves as indentation to my eyes.
from elixir_style_guide.
@chrismccord @alxndr that's an interesting way to think about it, one I hadn't considered
from elixir_style_guide.
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.
from elixir_style_guide.
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.
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.
@adamkittelson this was discussed at length in #33 and the second version was pretty much a consensus.
from elixir_style_guide.
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.
@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.
One more vote for single level of indentation. The |>
already provides enough guideline.
from elixir_style_guide.
@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. 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)
- Module naming with singular vs plural parent directory HOT 1
- camelCase vs PascalCase HOT 3
- Add preference for long args/`when` in methods? HOT 3
- Does the formatter make this obsolete? HOT 3
- Missing a section about maps HOT 5
- @module_attribute should be moved higher in Module attribute ordering HOT 1
- Establishing Guidelines for Maximizing Anonymous Function Readability in Reference to Escaped and Expanded Notations HOT 3
- Suggestion on Module Attribute Ordering HOT 1
- Thoughts on public/private function ordering HOT 4
- Deeply nested one-arity function calls? HOT 2
- new issue
- Placement of defguard? HOT 1
- using pipe with only 2 functions HOT 1
- Pipeline with single pipe operator for common cases like Enum.map/reduce/filter HOT 3
- Nested defmodule HOT 5
- Macro calls placement in a module HOT 1
- Naming: Modules HOT 1
- Clarification on multiline defs HOT 3
- cรณmo utilizamos?
- Racionalfor choice
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elixir_style_guide.