Open DavePearce opened 4 years ago
There are some interesting questions surrounding safe memory deallocation:
delete p
requires |>p<| == 1
then balloons cannot be deallocated. However, it is still be safe to deallocate the balloon if the reference was externally unique. For example, if we require only that after the deallocation |>p<| == 0
(which is in fact what we actually care about).
Currently Whiley has a somewhat unclear story about memory management. Specifically, how Whiley can be used without a garbage collector. There are essentially several pieces currently in play:
At this stage, I propose to remove reference lifetimes for Whiley as I no longer believe they are necessary for a
1.0
release. However, in the future, they may well make a come back as, in general, they are a nice solution.With the removal of reference lifetimes, we need an alternative approach to enable safe memory deallocation. The plan is to employ safe manual memory deallocation. This works by placing the burden of ensuring safety onto the verifier. Specifically, we pair the
new
expression for allocating memory with e.g.delete
statement for deallocating it. The verifier is then responsible for ensuring that the reference passed todelete
was unique.