Crazy code by Adam on SO

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 29 10:27:53 PDT 2014


On Fri, Aug 29, 2014 at 05:06:56PM +0000, Dicebot via Digitalmars-d wrote:
> On Friday, 29 August 2014 at 16:48:52 UTC, Andrei Alexandrescu wrote:
> >Worth a look:
> >
> >http://stackoverflow.com/questions/25555329/d-finding-all-functions-with-certain-attribute
> >
> >Andrei
> 
> This is exactly the stuff I have referring to in DConf talk as "must
> have things that are simple by concept but very hard to implement
> correctly for a newcomer" :) Exactly type of helpers I'd love to add
> in future std.meta

A lot of Adam's stuff are in that category.

One of the things I find eminently useful in my own code is the
pseudo-"slots-and-signals" design of arsd.eventloop, which contains a
particularly ingenious bit of code that does *runtime* dispatching of
signal types (basically structs) to handlers of the correct type
(delegates receiving structs of a specific type). The code figures out
which signals to send to which delegates *at runtime*. The way this is
done is to use the .mangleof of the struct's type as key to an AA of
arrays of handlers, suitably wrapped to allow runtime-binding of
incoming struct type to delegate parameter type. I highly recommending
studying how Adam's code achieves this. :-)


T

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


More information about the Digitalmars-d mailing list