Worst ideas/features in programming languages?

IGotD- nise at nise.com
Sat Oct 16 00:16:07 UTC 2021

On Friday, 15 October 2021 at 17:17:33 UTC, Araq wrote:
> The RC and metadata are stored at negative offsets.

I was thinking. One way for D which has common GC/raw pointers is 
to always allocate metadata at negative offsets. Then we D 
compiler can have hooks that runs when a pointer is copied, moved 
or goes out of scope.

At negative offsets can have a flag field that tells us if the 
memory is GC allocated or not. If it is not GC it just jumps over 
the hook code.

Drawbacks with this solution is the the raw C malloc/free cannot 
be used and a wrapped D version must be used that allocates 
additional space for the metadata. Also non GC memory will have a 
penalty with the hooks, as it needs to check the type all the 
time. For the current GC these hooks would be empty though.

Is this penalty we can live with?

More information about the Digitalmars-d mailing list