js.mdnq:
It seems one can accomplish this using delegates assigned by generic functions.
If you care so much for performance, when you work with D delegates it's useful to know the difference between static/scope delegates (that are just a fat pointer) and closures (that often induce a heap allocation).
Bye, bearophile