Returning variable-sized stack data

ryuukk_ ryuukk.dev at gmail.com
Mon Jul 15 11:12:59 UTC 2024


+1, however the syntax proposed sucks


```D
ubyte[$] get_variable_size_array(int cond) {
     if (cond == 0)
         return [1,2,3];
     else
         return [1,2,3,4,5];
}


// OR

scope(ubyte[]) get_variable_size_array(int cond) {
     if (cond == 0)
         return [1,2,3];
     else
         return [1,2,3,4,5];
}
```


More information about the dip.ideas mailing list