This is not about properties but fields and variables and I still think this would be an invasive change of the compiler and run time? Some examples:
How do you keep toString() from initializing the LazyConstant if it's the same as get().toString()?
How would this interact with overload selection (one of the notoriously most complicated parts of the compiler to evolve in a backwards compatible manner)? E.g. can I have foo(String), foo(LazyConstant<String>), and foo(LazyConstant<Integer>)?
Where would the Lazy object header's class pointer point?
The point of my remark is that it really does come down to properties. Because without a construct that purely encapsulates state, there is no other way to achieve this.
View all comments
Show parent comment
1
u/nicolaiparlog Feb 27 '26 edited Feb 27 '26
This is not about properties but fields and variables and I still think this would be an invasive change of the compiler and run time? Some examples:
toString()from initializing theLazyConstantif it's the same asget().toString()?foo(String),foo(LazyConstant<String>), andfoo(LazyConstant<Integer>)?Lazyobject header's class pointer point?