DIP1000: 'return scope' ambiguity and why you can't make opIndex work
Dennis
dkorpel at gmail.com
Tue Jul 6 09:45:49 UTC 2021
On Tuesday, 6 July 2021 at 09:37:30 UTC, Walter Bright wrote:
> It doesn't make sense to return either p or the address of p
> with the same function. What kind of a function does that?
Here's an example:
https://forum.dlang.org/post/uxtqfrbomcsfzzbefkyw@forum.dlang.org
But such a function should not be the norm. The point is that
users can simply add `return` and think "now I'm allowed to
return `this` or `&this.x` or `this.arr[0]` or whatever" without
delving into the whole "am I returning an address or value and am
I allowed to" conundrum.
> We could trick the code into doing that, but that would
> introduce all kinds of bugs into the lifetime analysis code.
Do you have an example?
> The real problem is not being able to return the value of p as
> a ref, if p is also passed by ref.
>
> I'm going to look into addressing that.
Awesome!
More information about the Digitalmars-d
mailing list