Discussion Thread: DIP 1042--ProtoObject--Community Review Round 1

Rumbu rumbu at rumbu.ro
Tue Jan 11 22:16:45 UTC 2022

On Tuesday, 11 January 2022 at 16:40:01 UTC, Adam D Ruppe wrote:
> On Tuesday, 11 January 2022 at 06:25:34 UTC, Rumbu wrote:
>> More than that, since it is a tight dependency between objects 
>> and the garbage collector, what improvement will render a 
>> @nogc thrown here and there? Currently there is little support 
>> în the language for using objects outside gc
> Using objects without the GC is very easy (just put the scope 
> keyword on the variable declaration).

Until now didn't found any use case for stack allocated objects. 
Most of objects are intended to be passed around and live longer 
than some local scope. I usually think of them as safe 
pointers/references and references are meant to be passed as 
arguments or to be used in composition of other objects, 
rendering their lifetime dependent of other objects.

If I really need a deterministic destruction or a stacked object, 
I rather use a struct than a class.

What I meant by lack of language support is missing of built-in 
object allocation outside the gc. (e.g. emplace).

The bottom line is that I don't find any use in constraining the 
cmp/eq/hash patterns to @nogc since 99% of use cases will wake up 
the gc anyway.

More information about the Digitalmars-d mailing list