The design suggestion Allow undentation for constructors has been marked "approved in principle". This RFC covers the detailed proposal for this suggestion and some related design relaxations.
- Approved in principle
- Discussion
- Implementation
F#'s indentation rules are overly stringent for the argument lists implicit constructors and static methods. This RFC relaxes the rules for these cases by adding some permitted "undentations".
Currently these all give the indentation warning FS0058 Possible incorrect indentation: this token is offside...
:
type OffsideCheck(a:int,
b:int, c:int, // Warning today, 'b' must align with 'a'
d:int) = ...
type C() =
static member M(a:int,
b:int, c:int, // Warning today, 'b' must align with 'a'
d:int) = 1
In each case a
sets the offside line and b
needs to be aligned with a
to avoid the warning.
Allowing "undentation" in these three cases would remove the warning.
It would also allow the following:
type OffsideCheck(
a:int, // Warning today, 'a' needs to be aligned with or after '('.
b:int, c:int) =
static member M(
a:int,
b:int, c:int, // Warning today, 'a' needs to be aligned after '('.
d:int) = 1
The following example may also be relaxed:
type C() =
static member P with get() =
1 // warning -- offside of 'member'
In all the above cases an undentation is added.
Constructor definitions and member definitions taking inputs, should be added to the list of permitted "undentations" in the F# language spec.
In the language of the spec, the "undentation" is permitted from the bracket starting a sequence of arguments in a definition, but the block must not "undent" past other offside lines.
None
The main alternative is "don't do this" and continue to require indentation.
This is a non-breaking change.
None