Is there a way to have warnings for shadowing values in F# in Visual Studio?

前端 未结 2 431
萌比男神i
萌比男神i 2021-01-18 02:10

To me shadowing of existing values like described in:

Shadowing and Nested function
immutable in F#
f# duplicate definition
FSharp for fun and profit com

2条回答
  •  醉话见心
    2021-01-18 02:53

    One place I use shadowing is when resolving an optional parameter to a default value if no value was supplied.

    member x.Foo(?myFlag: bool) =
        let myFlag = defaultArg myFlag false
        ...
    

    Also F# Interactive, the way it's implemented now, would be pretty much completely non-functional if we didn't have shadowing.

提交回复
热议问题