On Friday, 10 May 2024 at 13:27:40 UTC, Dukc wrote:
Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01:
On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:
This also gets inferred as `pure` - meaning that if you use
it twice for the same `WeakRef`, the compiler may reuse the
result of the
Steven Schveighoffer kirjoitti 10.5.2024 klo 16.01:
On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:
This also gets inferred as `pure` - meaning that if you use it twice
for the same `WeakRef`, the compiler may reuse the result of the first
dereference for the second call, without checking
On Friday, 10 May 2024 at 11:05:28 UTC, Dukc wrote:
This also gets inferred as `pure` - meaning that if you use it
twice for the same `WeakRef`, the compiler may reuse the result
of the first dereference for the second call, without checking
whether the referred value has changed!
This
evilrat kirjoitti 9.5.2024 klo 18.19:
```d
struct WeakRef(T) {
private size_t _handle; // same size as a pointer
this(T* ptr) {
_handle = cast(size_t) ptr;
}
T* getRef() {
return cast(T*) _handle;
}
// do the rest ...
}
```
[1]
On Thursday, 9 May 2024 at 00:39:49 UTC, Liam McGillivray wrote:
What's a good way I can achieve what I'm trying to do, using
either reference counting or a garbage-collected object?
There is libraries like `automem`[1] that implements refcounting
and more.
Without showing your code for ref
A "weak reference" (in the sense that I'm referring to) is a
feature in some programming languages for a reference to an
object that doesn't prevent the GC from destroying that object.
My current understanding is that D doesn't have weak references,
though I've found some posts in this forum