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. One obvious example would be synchronized properties/events.

Anyways, I threw together some code while thinking about what an event may look like in D:

DlangUI includes signal/slot event implementation.

https://github.com/buggins/dlangui/blob/master/src/dlangui/core/signals.d


Reply via email to