A new UDA is introduced: @manualScoped. It is valid for fields in structs and classes, as well as variables and parameters. Fields marked with @manualScoped are not automatically destructed on scope end.

For instance, a function taking a struct as a @manualScoped value will lead to a copy constructor call, but no destructor call. It is assumed the passed value will be moved into another field via move() or moveEmplace().

In @safe, only @manualScoped fields may be initialized with .init. This is to indicate that init represents a hole in the typesystem, and using it forces you to engage in manual lifecycle management.

The goal of this DIP is to make the union hack unnecessary and resolve the value/variable problem with .init initialized struct destruction, where { S s = S.init; } led to a destructor call but no corresponding constructor call.

Opinions?

Reply via email to