-
Notifications
You must be signed in to change notification settings - Fork 662
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
Allowing tabs for indentation #1370
Comments
What makes you believe that Elm does not require column alignment? |
The following program is legal Elm: import Html
main = let a = "a"
b = "b"
in Html.text (a ++ b) The following program is not legal Elm: import Html
main = let a = "a"
b = "b"
in Html.text (a ++ b) Doesn't that destroy your argument? (Edited the two programs slightly to make the point even clearer.) |
Sorry, I was unclear. What I ment was, you don't have to align by column like in Haskell:
It is more like indentation in Python. Thus, tabs work as indentation. |
No, they don't, as my example shows: import Html
main = let a = "a"
tab-tab-tab b = "b"
in Html.text (a ++ b) Depending on what the tab-size is, this program might or might not be correct Elm. |
Sure, but
is valid with tabs, and follows the style guide |
And how does that help? The following is valid Haskell: data Boolean = Literal Bool
| Not Boolean
| And Boolean Boolean
| Or Boolean Boolean Does that mean Haskell has reason to eschew tab characters? |
Sorry, meant "Does that mean Haskell has no reason to eschew tab characters?" in the previous comment. |
@drathier your latest example is the only one so far which is actually using indentation, the rest are using spacing - which is a different thing and shouldn't use tabs. |
Anyway, I'll defer to @evancz. I'm pretty sure the fact that import Html
main = let a = "a"
b = "b"
in Html.text (a ++ b) is a legal Elm program, while import Html
main = let a = "a"
b = "b"
in Html.text (a ++ b) is not a legal Elm program means that the compiler should not accept tabs (because what might look like a legal Elm program in some editor with some set tab size might not anymore look like a legal Elm program in some editor with another set tab size). |
But you can just add a line break, which makes tabs ok again:
|
I've said what I have to say. 😄 |
This style guide uses C-like (Go-like) syntax formatting that works great with tabs. I'm not forcing you to change, I just don't want to be forced myself, or forced to force others :) |
Pretty sure that could be one limitation when using tabs; it should be valid regardless of tab width. Shouldn't be too hard for the compiler/lexer to check. |
I'm aware of this idea. This repo is for tracking bugs with the compiler. If you have changes, it's best to discuss them in one of the community forums and build support. I follow this stuff. |
I think it's time to look at the tabs vs spaces debate. I currently do not see any reason to not allow tabs, as long as each file is consistent. The compiler could error out if a file mixes tabs and spaces.
The main argument for using tabs would be that some people prefer 2-space indentation, while others prefer 4 (or 8, 6 or 3). There's no reason to force everyone else to use the same indentation level as you are using. Setting the tab width in your editor of choice should be easy enough.
I'm assuming that the influence Haskell has on Elm is the reason Elm forces spaces for indentation. Haskell requires column alignment in the syntax, so varying tab width is dangerous to a haskell program. Elm does not.
The main benefit of using spaces is column alignment, but that's against the style guide anyway.
The text was updated successfully, but these errors were encountered: