4 ms·
I'm afraid I don't know about Rust, but D has the scope parameter storage class for this. It enables the following compiler-enforced guarantee: > The parameter
by MaxBarraclough 3y ago
I'm afraid I don't know about Rust, but D has the scope parameter storage class for this. It enables the following compiler-enforced guarantee:
> The parameter must not escape the function call (e.g. by being assigned to a global variable). Ignored for any parameter that is not a reference type.
https://dlang.org/spec/function.html#scope-parameters https://dlang.org/spec/function.html#scope-parameters
See also: https://dlang.org/blog/2023/10/02/crafting-self-evident-code-with-d/#self-documentingfunctiondeclarations https://dlang.org/blog/2023/10/02/crafting-self-evident-code... , https://news.ycombinator.com/item?id=37748543 https://news.ycombinator.com/item?id=37748543
- funnymony 3y agoLink to exact section: https://dlang.org/spec/function.html#scope-parameters https://dlang.org/spec/function.html#scope-parameters
- MaxBarraclough 3y agoGood call, have updated my links.
- pjmlp 3y agoNowadays also available in C#. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/statements/declarations#scoped-ref https://learn.microsoft.com/en-us/dotnet/csharp/language-ref...