-
Notifications
You must be signed in to change notification settings - Fork 7
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
Clarify constructors #11
base: master
Are you sure you want to change the base?
Conversation
At first glance, the other newline would be more consistent with anything I've seen so far. let person = {
Name = "barry"
} So from an implementation point of view, I welcome the extra newline. Does the example look the same when it is in an inner let binding? let myFunction () =
let thing =
new FooBar (
thing1,
thing2
)
() |
I think that looks right, except that I'm starting to think maybe it should be |
Looks like the rest of the team agrees that your suggestion is correct except for the space after the constructor (since I'm quite sure I remember there being times where |
Is it by the way always a multiline construct or does that depend on the arguments of the constructor? let thing = new Foobar(a, b)
let otherThing =
new Foobar(
thing1,
thing2
)
let m = new Meh(a) // what with only one argument? |
If the arguments fit on one line, we put them on one line: let thing = new Foobar(a, b)
let otherThing =
new Foobar(
longname1,
longname2
)
let m = new Meh(a) |
What if there is only one long argument? let myItem = new Foobar(someInitialStateThatHasQuietTheLongNameAndSeemsToGoOnAndOnAndOn) Would it be let myItem =
new Foobar(someInitialStateThatHasQuietTheLongNameAndSeemsToGoOnAndOnAndOn) or let myItem =
new Foobar(
someInitialStateThatHasQuietTheLongNameAndSeemsToGoOnAndOnAndOn
) |
I think we have no strong preference here; I'll pick arbitrarily. let myItem = new Foobar(someInitialStateThatHasQuietTheLongNameAndSeemsToGoOnAndOnAndOn) |
But that choice makes it more likely to surpass the possible horizontal limit of the dev to avoid horizontal scrolling. |
This is predicated on the assumption that we can't fit it all on one line. |
Slightly related does this rule also apply for member calls, static members? let myValue =
Regex.Match(
"my longer input string with some interesting content in it",
"myRegexPattern"
)
let untypedRes =
checker.ParseFile(
fileName,
sourceText,
parsingOptionsWithDefines
) |
I'd say it applies for those as well, yes. |
@Smaug123 dotnet/docs#21578 got merged, perhaps the same text can be added here as well. |
Sadly our "preferred" formatting is a syntax error due to offside indentation. That would be:
I've bitten the bullet and introduced another newline.
Aside: we are rather unclear on whether we want a space after the word
Foobar
here. I think sometimes it's a syntax error to insert a space.