[cap-talk] Specs for our 'ideal' language?
David Barbour
dmbarbour at gmail.com
Sat Sep 26 10:55:51 PDT 2009
On Sat, Sep 26, 2009 at 7:21 AM, Matej Kosik <kosik at fiit.stuba.sk> wrote:
> Can a language be "memory safe" and not to be "managed". Can a language
> be "managed" and not to be "memory safe"?
>
> http://en.wikipedia.org/wiki/Memory_safety
> http://en.wikipedia.org/wiki/Managed_code
> --
> Matej Kosik
Yes to both. Of course, the def. for 'managed code' you present
doesn't suggest managed code is necessary even for garbage collection.
To achieve memory-safety without GC requires some sort of memory-safe
semantics for explicit deletion of a memory-object that is still
referenced from elsewhere. Two possible semantics are: (a) refuses to
delete object that is referenced from elsewhere. (b) dereference
causes a particular exception (i.e. null-ptr exception).
In combination with concurrency, your memory-safe semantics need also
to handle the case of explicit delete from one thread while another
thread is still utilizing the memory-object. One might be able to
modify (b) for concurrency, via telling the object to self-terminate
the moment it is no longer in immediate use (i.e. by combining an
active usage-counter with the indirect reference).
A hybrid for (a) and (b) might be to use some equivalent of weakrefs
which are promoted to 'strong' refs explicitly or at need, but not
deleting until explicit destruction.
All of this is very expensive compared to plain-old garbage collection.
More information about the cap-talk
mailing list