-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
⌚ Not TriagedNot triagedNot triageddotnet-fsharp/svcframework-design/guidelinesIssues relates to the 2008 framework design guidelines.Issues relates to the 2008 framework design guidelines.
Milestone
Description
A few notes that I have regarding this great piece of work. Hopefully not too late and not too pretentious.
if
- I think there's more to expressions than just small expressions and large expressions. Could this be clarified a bit? How about differentiating between multi-line, single-line short (simple values) and single-line long (function evaluations) expressions?
- When
e1ande2are both single-line (short or long) expressions, I almost always choose this:I like the way it looks like aif cond then e1 else e2
match.thenandelseare same length - great coincidence (or design!) IMHO. I guess one drawback is that you kind of need IDE to highlight the relevant bits to look really nice. - I would personally avoid this even if expressions are of different size:
I prefer
if cond then e1 else e2
e1ande2to be at the same distance from the left side of the window (on the same level). The example above breaks the logical structure of the construct.
Lambdas
Why not like this:
let printListWithOffset a list1 =
List.iter
(fun elem ->
c1) // When c1 is multi-line
list1Or:
let printListWithOffset a list1 =
List.iter
(fun elem -> c1) // When c1 is single-line
list1This matches nicely with the function parameter application formatting guidelines. No dangling parentheses.
Other notes
- One-liner
matchexample looks complicated. Is there a good reason not to break that into three lines? - I'm missing guidelines on how to format explicit type declarations. Especially of interest are the more complicated cases - multiple parameters, generics, functions.
- I see value in the multi-line comments. When changing the content of the comment I often need to break the lines in different places than previously. In those cases the
//are in the way. - And finally, perhaps all of my questions could have been avoided :) I think it's very valuable with controversial topics such as style guides to have argumentation close at hand to justify the choices taken in more detail. Not necessarily in the guide itself, but perhaps in a separate article, or footnotes?
Again, thanks for the lovely work.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 8c09996f-24ac-cf39-ef43-d7909cbc2b89
- Version Independent ID: 1efdd523-8552-6421-e149-74f76826ef8f
- Content: F# code formatting guidelines
- Content Source: docs/fsharp/style-guide/formatting.md
- Service: unspecified
- Product: dotnet-fsharp
- GitHub Login: @cartermp
- Microsoft Alias: phcart
Metadata
Metadata
Assignees
Labels
⌚ Not TriagedNot triagedNot triageddotnet-fsharp/svcframework-design/guidelinesIssues relates to the 2008 framework design guidelines.Issues relates to the 2008 framework design guidelines.