Whiley / RFCs

Request for Comment (RFC) proposals for substantial changes to the Whiley language.
3 stars 2 forks source link

Safe Manual Memory Management #76

Open DavePearce opened 4 years ago

DavePearce commented 4 years ago

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 to delete was unique.

DavePearce commented 4 years ago

There are some interesting questions surrounding safe memory deallocation: