How to make delegate refer to itself?

H. S. Teoh hsteoh at quickfur.ath.cx
Sat Nov 23 15:33:11 PST 2013


On Sun, Nov 24, 2013 at 12:15:23AM +0100, lomereiter wrote:
> Why so much fuss about delegates? I would simply define an
> interface.
[...]

I know I can do that (and in fact it's what I had before).

But classes and interfaces are rather heavy (more indirection, allocates
vtables, etc.), and require the declaration of tiny classes everywhere,
which is a pain when I have many tiny code snippets I wish to register
and unregister in various places. Using delegates is much cleaner
(thanks to lambda syntax) and lighter weight, especially when I need to
close over local variables.


T

-- 
May you live all the days of your life. -- Jonathan Swift


More information about the Digitalmars-d-learn mailing list