[Dlang-study] [lifetime] Few root decisions to take on RC classes
Andrei Alexandrescu
andrei at erdani.com
Mon Nov 2 08:07:49 PST 2015
On 11/02/2015 10:52 AM, Martin Nowak wrote:
> On 11/02/2015 04:46 PM, Andrei Alexandrescu wrote:
>> Is Foo a class type or not?
>
> Let's assume Foo is an int.
Well so I'm unclear then. You asserted that code escaping a class
reference is in poor style and we needn't support it. But now you're
asserting code that escapes the address of an int is a "much more common
case". These two can't be simultaneously true.
I don't want to start a debate here, so let me ujust say what I think in
the matter:
* Classes are meant to be used as references, escape freely, etc.
* Structs and primitive data types are not supposed to escape freely in
safe code so we can afford to restrict escaping for them.
This seems to be the spirit of D. Want unrestricted use of references to
objects? Use class. Want value semantics and fewer guarantees regarding
escaping? Use non-class.
Andrei
More information about the Dlang-study
mailing list