Dennis Korpel
@safe
int[] escape() @safe { int[3] buf; int[] slice = buf[]; return slice; // Bug in safe: this is allowed }
scope
int[] escape() @safe { int[3] buf; int[] slice = buf[]; // Allowed, `scope` is inferred return slice; // Error: scope variable `slice` may not be returned }
int[] escape() @safe { int[3] buf; int[] slice = buf[]; // Error: can't take address return slice; }
dmd/escape.d
if
auto f(int* p) { ref p2 = p; return new int; }
std.array : array wrongly propagates scopeness of source
int[] fun() @safe { import std : array, map; scope r = [1,2,3].map!"a+3"; return r.array; }
Or at least opt-in?
auto: int[] identity(int[] x) => x; int* addrOf(ref int x) => &x; // Error: function `onlineapp.identity` // storage class `auto` has no effect if return type is not inferred
struct CtodContext { string source; HashMap!(string, Declaration) symbolTable; // ... }
scope[...]
Rikki's new syntax proposal
int** intRefOutPtr(@escape(return&) ref int* input) => &input;
https://github.com/marp-team/marpit/tree/main/docs
https://github.com/marp-team/marpit/blob/main/docs/image-syntax.md