I have a common pattern:
type something =
{
... a lot of stuff
}
member this.Description =
"a string description of the content, can be long tables, etc"
I would like the Description property to be evaluated ONLY when I need it; in many cases, it won't be used, but it could (mostly on a user's request).
I noticed that this code will cause Description to be evaluated even when it is not needed. So I moved the code to a function: Describe () and it solves the problem.
As I'm refactoring, I'm revisiting this. And while it won't make anything better in practice, I was wondering if something like:
member this.Describe =
(lazy "the long to build text output").Value
would solve the problem? because the lazy object will be created, but nothing may query the value itself.
Would that work reliably?