Returning a reference to be manipulated

kdevel kdevel at vogtner.de
Sat Apr 15 12:29:36 UTC 2023


On Friday, 14 April 2023 at 11:18:21 UTC, Dennis wrote:
> On Friday, 14 April 2023 at 10:31:58 UTC, kdevel wrote:
>> But in fact it is returned unless it is `return ref`.
>
> When using `return ref`, `return scope`, `scope` etc., you 
> should be using the latest compiler and annotate functions you 
> want checked with `@safe`.

We are writing at cross puroposes. I am not asking how I could 
help the compiler. My point is: I have code from 2019 which 
produced a deprecation warning

```
returnref2.d(3): Deprecation: returning i escapes a reference to 
parameter i, perhaps annotate with return
```

when compiled with with the compiler of that time (v2.093.1). 
When I use a recent compiler (v2.102.2) the code compiles without 
any complaints. I am asking myself what has deprecacted? I mean: 
Deprecation notes are built into the compiler in order to enable 
a "soft landing" for a scheduled breaking change. But I cannot 
see any breaking change at all regarding the code example in

https://forum.dlang.org/post/iysfuhjwyalnnmalbdrh@forum.dlang.org



More information about the Digitalmars-d-learn mailing list