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

Relax of indentation rules to allow tuples to have newline after the comma #777

Closed
4 of 5 tasks
et1975 opened this issue Aug 21, 2019 · 7 comments
Closed
4 of 5 tasks

Comments

@et1975
Copy link

et1975 commented Aug 21, 2019

Relax of indentation rules to allow tuples to have newline after the comma

So that one could write something like:

let v : _*_ =
    1,
    2

instead of:

let v : _*_ =
    1
    ,2

Currently it is possible to wrap the tuple in () and get the desired newlines that way, but it seems noisy and it introduces itsown tab stop.

Pros and Cons

Pros: Less noise and more consistency with how commas are usually placed.

The disadvantages of making this adjustment to F# are ...
None that I can think of.

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S?

Related suggestions:
#724
#470

Affidavit

Please tick this by placing a cross in the box:

  • This is not a question (e.g. like one you might ask on stackoverflow) and I have searched stackoverflow for discussions of this issue
  • I have searched both open and closed suggestions on this site and believe this is not a duplicate
  • This is not something which has obviously "already been decided" in previous versions of F#. If you're questioning a fundamental design decision that has obviously already been taken (e.g. "Make F# untyped") then please don't submit it.

Please tick all that apply:

  • This is not a breaking change to the F# language design
  • I or my company would be willing to help implement and/or test this
@cartermp
Copy link
Member

I'd like to see this if possible

@dsyme
Copy link
Collaborator

dsyme commented Aug 22, 2019

I just checked master and both work today:

let v : _*_ =
    1,
    2

giving

val v : int * int = (1, 2)

@et1975
Copy link
Author

et1975 commented Aug 22, 2019

I thought I oversimplified the example, but it looks like I just haven't tried writing it like that in a while.

@et1975 et1975 closed this as completed Aug 22, 2019
@Happypig375
Copy link
Contributor

Please reopen. This should also apply for
static member M(a:int->int, b:int) and

M(a=fun a -> a + 1,
  b=1)

Currently disallowed.

@dsyme
Copy link
Collaborator

dsyme commented Aug 22, 2019

That one is by design, because of the undentation rule for fun

@dsyme
Copy link
Collaborator

dsyme commented Aug 22, 2019

The only solution that would not require parens would be to allow a a => b function syntax where => had higher precedence than ,, e.g.

M(a=a=>a + 1, b=1)

or

M(a=a=>a + 1,
  b=1)

I don't think simply dropping the fun can be made to work with the right precedences but I may be wrong - but in any case changing the precedence of -> when the fun is dropped seems wonky

M(a=a->a + 1, b=1)

@Happypig375
Copy link
Contributor

But the b=1 is one level lower in indentation, so tuple shouldn't be considered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants