describe-d: an introspection library

Jean-Louis Leroy jl at leroy.nyc
Tue Apr 21 14:43:04 UTC 2020


On Wednesday, 15 April 2020 at 08:00:12 UTC, bogdan wrote:

I use a similar approach in openmethods. With the added twist 
that I need to re-create functions from existing functions, with 
some modifications (e.g. change the parameter types, add a 
parameter), while preserving function and parameter attributes. 
That inevitably leads to constructing mixin code (which I call 
"mixtures"), and it has to  work across module boundaries (i.e. 
use `ReturnType!F` in the mixture, not the stringified type).

See here:
https://github.com/jll63/openmethods.d/blob/master/source/openmethods.d#L503, here: https://github.com/jll63/openmethods.d/blob/master/source/openmethods.d#L568 and here: https://github.com/jll63/openmethods.d/blob/master/source/bolts/reflection/metafunction.d

I did not shy away from using templates and indeed there is a 
significant increase in compilation time. On the other hand, the 
code is much cleaner than a previous iteration that created the 
mixtures directly.

If these techniques get traction, it will incite compiler 
developers to improve template instantiation, hopefully.

I wonder if templates are lazily expanded. I haven't looked at 
the compiler's code, my guess is: maybe not.


More information about the Digitalmars-d-announce mailing list