DIP1000: The return of 'Extend Return Scope Semantics'

jmh530 john.michael.hall at gmail.com
Wed May 26 15:49:09 UTC 2021


On Wednesday, 26 May 2021 at 15:29:32 UTC, Paul Backus wrote:
> [snip]
>
> D's general philosophy w.r.t. memory safety so far has been to 
> try and balance ease of use and comprehension with 
> expressiveness. D's `scope` and `return` are less expressive 
> than Rust's lifetimes, but that expressiveness may be worth 
> giving up if it's easier to write correct `@safe` and 
> DIP1000-compliant code than it is to write correct Rust code.
>

Correct me if I'm wrong, but Rust bakes in D's `scope` to 
everything unless you override it with a lifetime annotation. So 
I don't think the issue is `scope` per se. `return` is what is 
used to tie the lifetime of a parameter to the lifetime of the 
output. I agree that in the simple example it is easier to write 
correct code.

> Of course, D's vision here is severely hampered in practice by 
> the poor quality of its documentation (raise your hand if you 
> can explain what ["return ref parameter semantics with 
> additional scope parameter semantics"][1] actually means). But 
> that's the idea.
>
> [1]: 
> https://dlang.org/spec/function.html#ref-return-scope-parameters

+1


More information about the Digitalmars-d mailing list