Challenge: write a template-instance free dispatcher for text printing
H. S. Teoh
hsteoh at qfbox.info
Wed May 27 18:13:40 UTC 2026
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
--
Study gravitation, it's a field with a lot of potential.
More information about the Digitalmars-d
mailing list