PhobosV3+ Fundamental Elements

Max Klyga max.klyga at gmail.com
Wed Sep 2 13:17:35 UTC 2026


On Thursday, 27 August 2026 at 22:39:04 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> ...snip...
> The solution to this is to introduce a string builder, similar 
> to C#'s that is not templated.
>
> To format a type using such a string builder would require the 
> following signature for the hook method:
>
> ```d
> struct Type {
> 	void toString(scope StringBuilder) scope const;
> }
> ```

Please don't do this. Not like this 🤦

This was discussed a million times and we have a existing 
solutions to this (`std.algorithm.joiner`, `std.conv.text`, 
`std.array.appender`)
Templates are just a fundamentally a better way of dealing with 
this.

The correct way is to have a generic sink, not a string builder. 
And especially not a specific string builder class implementation!


More information about the Digitalmars-d mailing list