Replies: 3 comments 5 replies
-
Actually there's no need to invent a new keyword, it already exists (for classes): An inconvenient is that this would turn |
Beta Was this translation helpful? Give feedback.
-
I think there are more options on how to accomplish this goal, and the language does not need another one:
Do we perhaps need more explicit docs about Another angle, often times it is demanding to re-evaluate every time even if the caching would be automatic (e.g. computing |
Beta Was this translation helpful? Give feedback.
-
I have opened this issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Has there been a proposal to enable evaluating record properties only once as explained here:
https://stackoverflow.com/questions/2873125/f-record-member-evaluation
I am not able to find one, but i find it surprising so i suspect i may not be using the right search terms.
Sometimes, read only properties of records may do relatively expensive computations, and if you are doing aggregations accessing these properties multiple times on large number of records, this computation time may start to matter.
My idea would be to add a keyword to record member declaration to indicate that the member should only be evaluated once. Could be as easy as making the compiler create a backing field, and move the body of the expression to the constructor of the record.
Or alternatively we could also allow the let keyword in the context of record, to indicate that the member is a public field that will only be evaluated once. But this approach sounds more complex.
Beta Was this translation helpful? Give feedback.
All reactions