Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
84 lines (56 sloc) 2.38 KB

F# RFC FS-1070 - Offside relaxations for construct and member definitions

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.

Summary

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".

Code Examples

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

Possibly related: with get and with set

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.

Detailed Design

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.

Drawbacks

None

Alternatives

The main alternative is "don't do this" and continue to require indentation.

Compatibility

This is a non-breaking change.

Unresolved questions

None

You can’t perform that action at this time.