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

Should we enforce consistency of a final semicolon in parentheses or begin/end? #619

Open
Niols opened this issue Sep 7, 2023 · 3 comments
Labels
epic: language-support Relates to the number of languages Topiary supports and how well they are supported language: ocaml OCaml formatting issues

Comments

@Niols
Copy link
Member

Niols commented Sep 7, 2023

As of 3964d3c, Topiary formats both:

(
  foo;
  bar
)

and

(
  foo;
  bar;
)

as they are. (And same with begin/end.)

For the single-line style, Topiary formats:

(foo; bar)

and

(foo; bar; )

as they are. (While we're at it, note the space after the last semi-colon.)

This makes me wonder whether we shouldn't enforce consistency of those styles, the same way we do it with records and lists, for instance. The style would therefore be:

(foo; bar)

for single-line, and:

(
  foo;
  bar;
)

for multi-line.

I am however a bit afraid that this might make aerated single-element parentheses very ugly, namely:

(
  foo
)

would always have to be:

(
  foo;
)

and I think this would interact potentially very poorly with multi-line functions or matches as parameters, for instance. Any ideas? @aspiwack and @nbacquey in particular?

@Niols Niols added the language: ocaml OCaml formatting issues label Sep 7, 2023
@Niols
Copy link
Member Author

Niols commented Sep 7, 2023

Actually, I don't think we enforce this style in records and lists. I had in mind that we did, but maybe it is just hard to do?

@nbacquey
Copy link
Member

nbacquey commented Sep 7, 2023

This problem has a large amount of complexity when you factor in comments and attributes. I'd recommend not to try addressing this properly before #430 is done.

@ErinvanderVeen ErinvanderVeen added the epic: language-support Relates to the number of languages Topiary supports and how well they are supported label Sep 28, 2023
@Niols
Copy link
Member Author

Niols commented Dec 1, 2023

Actually, I'm wondering if the rule shouldn't be that when tuples/lists/arrays have only one element, then there is no last separator, even in multi-line mode; when there are more than one elements in single-line mode, still no last separator; and when there are more than one elements in multi-line mode, then there should be a last separator.

This rule is not very nice with respect to Git diffs, and systematically adding a last separator in multi-line mode might make more sense for that. However, I think it might be pretty shocking for people to have a list of one element with a separator. It is also maybe fine to have singletons handled in a different way because it is usually not random that something is a singleton.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic: language-support Relates to the number of languages Topiary supports and how well they are supported language: ocaml OCaml formatting issues
Projects
None yet
Development

No branches or pull requests

3 participants