November 26, 2020
On Thursday, 26 November 2020 at 06:28:03 UTC, Walter Bright wrote:
>> As what kind of other pointer? I quess `new int()` returns a pointer that is treated as `return scope`, right?
>
> No, it returns `int*`.

Huh? Won't that make the compiler to think the programmer is leaking the pointer when it exits the scope? If I understood correctly, `@live` requires freeing any non-null `int*`, or forwarding them to a function that takes them as non-scoped `int*`.
November 26, 2020
On Thursday, 26 November 2020 at 13:07:38 UTC, Dukc wrote:
>
> Huh? Won't that make the compiler to think the programmer is leaking the pointer when it exits the scope? If I understood correctly, `@live` requires freeing any non-null `int*`, or forwarding them to a function that takes them as non-scoped `int*`.

Or do you mean one has to do this:

```
void leak(T)(T* ptr){}

@live void useGc()
{  auto ptr = new int(5);
   writeln(*ptr);
   ptr.leak;
}
```
?

Now when I think of it, it might make some sense. You obviously do not want this when all memory is garbage-collected or intentionally leaked. But if one has to use `free()` it might be worth the additional hassle.
November 27, 2020
On Wednesday, 25 November 2020 at 10:51:12 UTC, Walter Bright wrote:
>
> It's not that it can't deal with them. It's that it treats them as any other pointer.
>
> Adding a type constructor that says "this pointer is a GC pointer" is a major escalation in complexity of the language. Other languages have done it (see Microsoft's "Managed C++") but I don't think it caught on because I haven't heard much about it in years.

The problem I can't see any way out of this, we need a managed pointer type. For example if we want to change the GC type globally (everything in libraries like arrays and so on) we need some kind of fat pointer that is generic. Now we are stuck in tracing GC land forever and projects cannot choose what GC that suits their need.

Sure we have a reference counted in the library but this is something the programmer adds but the library is still using traced GC.

Only raw pointers is limiting the versatility of D.
1 2 3 4
Next ›   Last »