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;
On Sun, 09 Oct 2011 13:52:47 -0400, bearophile
wrote:
(I show this here because it's probably a silly idea, but it may a
chance to learn something.)
Do you like the idea of a POD that is always managed by reference, as
class instances?
ref struct Foo {}
static assert(Foo.sizeof
Am 09.10.2011 19:52, schrieb bearophile:
(I show this here because it's probably a silly idea, but it may a chance to
learn something.)
Do you like the idea of a POD that is always managed by reference, as class
instances?
ref struct Foo {}
static assert(Foo.sizeof == 1);
void
On 10/11/11, bearophile wrote:
> Andrej Mitrovic:
>
>> I think this is what refcounted structs are for.
>
> "ref structs" are regular heap-allocated GC-managed structs, but they are
> managed by reference instead of by pointer. So refcounting is not
> significant here.
But can't you just make a w
Andrej Mitrovic:
> I think this is what refcounted structs are for.
"ref structs" are regular heap-allocated GC-managed structs, but they are
managed by reference instead of by pointer. So refcounting is not significant
here.
--
Jonathan M Davis:
> That or make it a c
On Sunday, October 09, 2011 22:42:35 Andrej Mitrovic wrote:
> I think this is what refcounted structs are for.
That or make it a class and make it final.
- Jonathan M Davis
I think this is what refcounted structs are for.
(I show this here because it's probably a silly idea, but it may a chance to
learn something.)
Do you like the idea of a POD that is always managed by reference, as class
instances?
ref struct Foo {}
static assert(Foo.sizeof == 1);
void main() {
Foo f1; // void reference
Foo f2
13 matches
Mail list logo