In this paragraph it states that useContents "temporarily places the CValue to memory, and then runs the passed lambda with this placed value T as receiver".
A few questions about this:
- Since this implies that
Tis not in memory at this moment, is there a risk thatuseContentsfails because the value no longer available? - What happens if I do this:
val foo = bar.useContents { this }. Does this copyT? Is it now in memory permanently? Do I need to clean it up manually somehow? - Why is this even necessary? Can't the compiler take care of these details? I just end up writing a lot of extension functions to hide
useContents.