Challenge: write a template-instance free dispatcher for text printing

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Wed May 27 18:19:49 UTC 2026


On 28/05/2026 6:13 AM, H. S. Teoh wrote:
> On Thu, May 28, 2026 at 04:44:56AM +1200, Richard (Rikki) Andrew Cattermole via Digitalmars-d wrote:
>> On 27/05/2026 6:33 PM, Atila Neves wrote:
> [...]
>>> What's expensive about string mixins?
>>
>> That snippet of code, needs: new file name, lexed, parsed, create
>> parse tree, then semantic, then combined back into previous AST.
>>
>> Versus: copy parse tree, run semantic, append to list.
>>
>> Compared to the base line there is a lot of infrastructure being
>> touched that doesn't need to be if it was modelled by the language.
> [...]
>> They also happen to encourage templates, which on top of the base line
>> create at a minimum one new symbol that may get emitted into the
>> object file.
>>
>> So avoiding string mixins is a good thing for a library to do, at
>> least in hot code.
> 
> Makes me really wish for Stefan's' CTFE engine + CT type manipulation
> support.
> 
> Although D templates are extremely powerful and awesome for
> metaprogramming, templates are ultimately not the right concept for many
> CT tasks. What we *really* want is CTFE + type manipulation for DbI to
> compute the final form of a template instantiation, then a single
> template instantiation at the end to actualize it.  The current idiom of
> arbitrarily-complex templates nested arbitrarily deep, while powerful,
> leads to needless template bloat.
> 
> 
> T
What I'm suspecting here is missing control flow capabilities and 
dynamic variables.

enum assign (similar to alias assign) + static while, I suspect would 
solve this particular problem nicely.

Oh and being able to create alias sequences without needing a 
template... that would be helpful.

Maybe break for static foreach/static while too.



More information about the Digitalmars-d mailing list