On 1/9/13 12:09 PM, Mehrdad wrote:
On Wednesday, 9 January 2013 at 19:34:19 UTC, Andrei Alexandrescu wrote:
At the end of the day if references are part of the language and
programs can build arbitrary reference topologies, safety entails GC.


It looks like a non sequitur to me... wouldn't this work?

A language X has a built-in data type called Reference, and no classes.

The only thing you can do with it are using these functions:

Reference CreateObject(Reference typename);
Reference DeleteValue(Reference object, Reference field);
Reference GetValue(Reference object, Reference field);
Reference SetValue(Reference object, Reference field, Reference value);

Given _just_ these functions you can build _any_ arbitrary reference
topology whatsoever. There's no need for a GC to be running, and it's
completely manual memory management.


It's memory-safe too. What am I missing here?

What you're missing is that you define a store that doesn't model object references with object addresses. That's what I meant by "references are part of the language". If store is modeled by actual memory (i.e. accessing an object handle takes you to the object), you must have GC for the language to be safe. If store is actually indirected and gives up on the notion of address, then sure you can implement safety checks. The thing is everybody wants for references to model actual object addresses; indirect handles as the core abstraction are uninteresting.


Andrei

Reply via email to