On Tuesday, 29 August 2017 at 05:10:25 UTC, bitwise wrote:
I needed some C# style events, so I rolled my own. Long story short, the result was unsatisfactory.

Library based events are inadequate for basically the same reasons as library based properties (often suggested/attempted in C++). The problem is that the properties/events don't have access to the fields or methods of the containing object, and as such, incur the cost of an extra pointer per event/property, or worse, a delegate if custom behavior per event is needed, in order to provide that access.

I'm confused, C# has the same problem with events. They are delegates which under the hood have 2 pointers, a pointer to the method and a pointer to an instance of the object. How would that be different than if you used delegates in your D library?


Reply via email to