On Friday, 14 May 2021 at 10:00:28 UTC, PinDPlugga wrote:
Hi thank you both for your answers. I had understood from an
earlier chapter how this could introduce a bug, but I was
confused because the warning suggests attaching ```return``` to
the parameter, which is empty in the declaration.
On 14.05.21 12:00, PinDPlugga wrote:
Hi thank you both for your answers. I had understood from an earlier
chapter how this could introduce a bug, but I was confused because the
warning suggests attaching ```return``` to the parameter, which is empty
in the declaration.
`this` is considered a
On Thursday, 13 May 2021 at 19:48:44 UTC, Ali Çehreli wrote:
I was writing this example that shows a use case for the
problem (marked with BUG below):
```D
struct Fraction {
auto n = 0L;
auto d = 1L;
// ... other bits ...
ref Fraction reduce() {
import std.numeric : gcd;
On 5/13/21 12:40 PM, Steven Schveighoffer wrote:
On 5/13/21 3:21 PM, PinDPlugga wrote:
This works but issues a deprecation warning:
```
onlineapp.d(30): Deprecation: returning `this` escapes a reference to
parameter `this`
onlineapp.d(30): perhaps annotate the parameter with `return`
F
On 5/13/21 3:21 PM, PinDPlugga wrote:
This works but issues a deprecation warning:
```
onlineapp.d(30): Deprecation: returning `this` escapes a reference to
parameter `this`
onlineapp.d(30): perhaps annotate the parameter with `return`
Fraction(1, 3)
```
I found several other ways to m
Hi I am working through Programming in D. In one exercise I have
a helper function in a struct
```D
struct Fraction {
auto n = 0L;
auto d = 1L;
// ... other bits ...
ref Fraction reduce() {
import std.numeric : gcd;
v = gcd(n, d);
if (v > 1) {
n /= v;