If you could make any changes to D, what would they look like?

IGotD- nise at nise.com
Wed Oct 20 18:03:39 UTC 2021


On Wednesday, 20 October 2021 at 17:55:05 UTC, IGotD- wrote:
>
> Correct, that is the drawback with different pointer types, 
> that you might need two implementations, one for pointers and 
> one for reference types. Normally generics takes care of that 
> pretty well.
>
> The benefit is that references/fat-pointers enables operations 
> under the hood that raw pointers don't allow. For example 
> increasing/decreasing a reference count. If everything in 
> Phobos/Druntime would use references instead of raw pointers 
> where applicable, the a recompile would have enabled a complete 
> change of the GC algorithm. Reference types enables more 
> versatility.

The more I think of it, this solution is becoming more and more 
attractive.

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

I know that a reference type will never make it into D. However, 
the solution proposed offers an escape hatch without changing the 
core language. Managed memory is the norm and unmanaged memory 
will likely be used sparsely in most programs. There will be an 
unnecessary performance hit when using unmanaged memory (which is 
still managed but operations ignored at runtime) but it can be 
overridden (for example parameter passing) by a keyword for those 
very optimized situations which is a non breaking change.


More information about the Digitalmars-d mailing list