On Monday, 6 May 2013 at 21:26:03 UTC, Luís Marques wrote:
On Monday, 6 May 2013 at 21:20:49 UTC, Idan Arye wrote:
BTW, for this to work `typeHandler.type` needs to be known at
compile-time.
That's the rub. This list of handler is dynamic, so
`typeHandler.type` is a TypeInfo, not a compile-time type.
If the type handlers are your own classes, then you can let them
check it. Have a method in the handlers that check if an object
can be handled by that handler, and use it on each handler until
you find one that fits.