On Wednesday, 10 May 2017 at 14:03:58 UTC, Biotronic wrote:
On Wednesday, 10 May 2017 at 11:45:05 UTC, Moritz Maxeiner wrote:
[CTFE slow]

First, as you may know, Stefan Koch is working on an improved CTFE engine that will hopefully make things a lot better.

As he already pointed out, it won't help with the introspection template costs, though.


As for making the code faster right now, could this be done with mixin templates instead?

Something like:

[...]

This will move from CTFE to templates, sure, but templates aren't that fast, either. I'll experiment with your suggestion regardless to see what it'll result in, but I'm not very optimistic about that solving the issue.


(tests indicate this compiles but doesn't run, and I'm helping you on company time, so I can't fix everything right now :p)


Thank you, I'll gladly take any advice and try to optimize things, though my primary purpose with this post was not to ask for help (for once :p ), but to publicize my experience with compile time introspection costs as a reference for others (and because a certain someone asked me too - you know who you are).


[...]

A few things here - functions.fn would not do what you want, and neither would __traits(identifier). functions.fn would treat "fn" like a part of name, not a string value, so this will make the poor compiler barf. __traits(identifier, fn) expects fn to be a symbol, while here it's a string. In fact, it's exactly the string you want __traits to return. Lastly, you'll still need a mixin, whether it's for __traits(identifier, fn) or just fn - they're just strings.

Right, but it'll still be one fairly short, readable line in the end (that should be faster than CTFE).

Reply via email to