DIP1000 scope inference
German Diago
germandiago at gmail.com
Wed Oct 26 10:43:11 UTC 2022
On Wednesday, 26 October 2022 at 08:03:37 UTC, Walter Bright
wrote:
> A very good question. Clearly, having code work when it is
> @safe, but cause memory corruption when it is marked @trusted,
> is the wrong solution. This should never happen. I'm not sure
> what the solution should be here.
Is not trusted code (note my little D experience so sorry if I am
asking something relatively stupid) unsafe? I mean, @safe is
safe, @trusted is ??, @system is you go your own.
- So what are the guarantees of @trusted compared to @system?
Also, as far as I understood from my limited D usage, only
type[N] are static arrays on the stack and the rest are
GC-allocated, by default, right?
So in the presence of scope, probably that should be a
dynamically sized array that was to be "freed" by the GC and
invalid at the end of the function.
I would assume a move can be done if the array is not static,
independently of scope being there or not and an error if it is
statically allocated, since the return type is type[] (without
explicit size in the type).
More information about the Digitalmars-d
mailing list