For example:
private Foo = 1
A = 2
How is this file formatted?
I consider 2 behaviors:
private Foo = 1
A = 2
private Foo = 1
A = 2
The 1 is pretty good, but this implementation will be heavy, I think. The 2 is not the best, but we can implement it easily.
Which do you like? Or do you have any idea?
I would keep the first one, for me the 2 should not be in the same segment, and maybe the formatter should even separate them.
The visibility is different, the formatting should clearly show that:
private Foo = 1
protected Bar = 4
protected FooBar = 5
Fizz = 10
For me should be formatted as:
private Foo = 1
protected Bar = 4
protected FooBar = 5
Fizz = 10
I wish constants weren't aligned on their assignment. We'd have a nicer-to-read-patch-diff:
Short = 1
- VeryLongConstant = 2
+ Renamed = 2
Instead of:
- Short = 1
- VeryLongConstant = 2
+ Short = 1
+ Renamed = 2
Then @bew's example would lead to no change by the formatter:
private Foo = 1
protected Bar = 4
protected FooBar = 5
Fizz = 10
@ysbaddaden unless we switch to elastic-tabstops I think those extra diff lines are things we will need to ~deal with~ live with. And the editors haven't catch up yet to use elastic-tabstops, I don't see that changing any time soon.
I have more general question.
Should the following segment be separated?
private property foo : String
private property bar : Int32
protected property fizz : String
protected property buzz : String
↓
private property foo : String
private property bar : Int32
protected property fizz : String
protected property buzz : String
In other words, should we separate segments by visibility modifiers?
@MakeNowJust I don't think so. I would aim for aligning constants only.
Otherwise, maybe:
property foo = false
property longer_foo = false
property foo
@bar = 42
property baz
currently we do nothing on those cases and I sometimes mix them (might not be the best thing to do, but is how my code sometimes evolve, putting related props/ivars together).
constants, since they are read only they don't "suffer" that use case.
I have a strong preference for the first suggestion in the @MakeNowJust 's message over all the others for 2 reasons:
I agree with @cluxter's opinion. And, the formatter should not separate lines without user's intention in almost all case.
Personally I would like to see @bew's suggestion, judging by the reactions it has quite a bit of support too.
What's the last stand on this?
My suggestion is that the compiler shouldn't align things, ever. It was a mistake.
Are diffs really an issue? On github at least we have ?w=1
.
Most helpful comment
I would keep the first one, for me the 2 should not be in the same segment, and maybe the formatter should even separate them.
The visibility is different, the formatting should clearly show that:
For me should be formatted as: