On Saturday, 26 June 2021 at 07:39:44 UTC, kinke wrote:
I'm pretty sure I haven't seen a weak pointer in C++ yet. I don't look at C++ much anymore, but I suspect they are even a lot rarer than shared_ptr.

Weak pointers are usually not needed, but sometimes you do need them and then not having them becomes a big weakness. Usually ones strives to have ownership defined in a way that makes it possible to dismantle a graph in a structured way from a single thread, and then weak pointers are not needed at all.

Wrt. mixed class hierarchies, being able to inherit from and instantiate C++ classes in D is of some priority and mostly works today. (Let's not get into discussing multiple inheritance here, it's hardly a show-stopper for most use cases.)

Is it possible to inherit from a C++ class and get a D subclass, and is it possible to inherit from a D class and get a C++ class?

Is Swift a thing outside the Apple universe (I admittedly despise ;))? It's surely much better than their Objective-C crap, but still...

The Apple universe is pretty big, we can dislike that, but that does not change the market…

So the goal would be to put the ref-count on a negative offset so that the layout can match up with C++ or Swift. I don't think that implies any big disadvantages, but I could be wrong. The only way to find out is to hash out the alternatives.

So for rare use cases like shared_ptr/weak pointer interop, a library solution (just like they are in C++) is IMO enough.

But the best solution is to get to a place where you can hand D-objects to other languages with ease without doing a runtime conversion from one layout to another.

Reply via email to