F# record member evaluation
问题 Why is t.b evaluated on every call? And is there any way how to make it evaluate only once? type test = { a: float } member x.b = printfn "oh no" x.a * 2. let t = { a = 1. } t.b t.b 回答1: It's a property; you're basically calling the get_b() member. If you want the effect to happen once with the constructor, you could use a class: type Test(a:float) = // constructor let b = // compute it once, store it in a field in the class printfn "oh no" a * 2. // properties member this.A = a member this.B