I propose we allow hash directives to take integers, floats, and (long) identifiers, so we can write #time on and #nowarn 1234. At the same time, this syntax is not prescriptive in the F# spec, I propose to formalize it so we can reason about it.
The existing way of approaching this problem in F# is: write #time "on" or #nowarn "1234".
Pros and Cons
The advantages of making this adjustment to F# are
We can now simplify the use of, and expand the scope of allowed types for existing directives. This allows tokens like #nowarn to take not only a number, but also FS1104 as input, which is the form in which warnings are output. It is also the form that's accepted already on the commandline.
Formalizing the syntax helps to reason about it, and makes it easier to add new directives or expand on existing ones.
Before:
#nowarn "0070"
#nowarn "FS1140" // error
#nowarn "0025" "1140" "1234"
#time "on"
#r "System.Core"
After:
#nowarn 70
#nowarn 25 1140 1234
#nowarn "FS1140" // string is still allowed
#nowarn FS1140
#time on
#r System.Core
The disadvantages of making this adjustment to F# are
None that I can think of.
Extra information
Please note that this change does not intend to change the behavior of these constructs. It merely allows more freedom with the syntax of the arguments, and formalizes the syntax of the status quo.
Estimated cost (XS, S, M, L, XL, XXL): XS
This work has already been started (see dotnet/fsharp#17206). @dsyme, if that PR is accepted, could you do the honors and mark this approved so that we can create an RFC for this?
Related suggestions:
Affidavit (please submit!)
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.
I propose we allow hash directives to take integers, floats, and (long) identifiers, so we can write
#time onand#nowarn 1234. At the same time, this syntax is not prescriptive in the F# spec, I propose to formalize it so we can reason about it.The existing way of approaching this problem in F# is: write
#time "on"or#nowarn "1234".Pros and Cons
The advantages of making this adjustment to F# are
We can now simplify the use of, and expand the scope of allowed types for existing directives. This allows tokens like
#nowarnto take not only a number, but alsoFS1104as input, which is the form in which warnings are output. It is also the form that's accepted already on the commandline.Formalizing the syntax helps to reason about it, and makes it easier to add new directives or expand on existing ones.
Before:
After:
The disadvantages of making this adjustment to F# are
None that I can think of.
Extra information
Please note that this change does not intend to change the behavior of these constructs. It merely allows more freedom with the syntax of the arguments, and formalizes the syntax of the status quo.
Estimated cost (XS, S, M, L, XL, XXL): XS
This work has already been started (see dotnet/fsharp#17206). @dsyme, if that PR is accepted, could you do the honors and mark this approved so that we can create an RFC for this?
Related suggestions:
Affidavit (please submit!)
Please tick these items by placing a cross in the box:
Please tick all that apply:
For Readers
If you would like to see this issue implemented, please click the 👍 emoji on this issue. These counts are used to generally order the suggestions by engagement.