DIP1000: Walter's proposal to resolve ambiguity of ref-return-scope parameters

Dukc ajieskola at gmail.com
Thu Nov 25 08:51:21 UTC 2021


On Thursday, 25 November 2021 at 08:20:32 UTC, Walter Bright 
wrote:
> On 11/25/2021 12:12 AM, Dukc wrote:
>> This raises a question: will `return ref return scope` become 
>> allowed?
>
> No.
>
> Consider the following code:
>
>   void* func(T** p, bool b)
>   {
>      if (b)
> 	return p;
>      else
>         return *p;
>   }
>
> I propose that such code has quite a smell emanating from it, 
> and so don't see a good reason to support `return ref return 
> scope` as that will endorse such code.

Lol, I obviously wasn't thinking much what the qualifier set 
would mean. Good point, that would be a bit like having `string 
roundToInteger(float)` in Phobos.


More information about the Digitalmars-d mailing list