From the D Blog: The Amazing Compile-Time Metaprogramming State Machine

Meta jared771 at gmail.com
Sat May 9 03:18:41 UTC 2026


On Friday, 8 May 2026 at 19:09:58 UTC, Dave P. wrote:
> On Friday, 8 May 2026 at 05:05:07 UTC, Mike Parker wrote:
>> A new blog post from Jared Hanson is live. In this one, he 
>> shows how to use D's compile-time features to create a 
>> type-safe, compile-time implementation of the Builder pattern.
>>
>> https://blog.dlang.org/2026/05/05/the-amazing-compile-time-state-machine/
>
> Is there complete code somewhere? I can’t get the examples to 
> compile beyond the first one and the rest elide re-used 
> sections beyond the first.

I wanted to include a shortlink from run.dlang.io, but that seems 
to be broken now and I can't create one. Here's a gist:

https://gist.github.com/MetaLang/15c2c26e1b387a151401810ad936ad3a

I lied a little bit in the article - `static assert` doesn't 
actually work in this case because opDispatch swallows errors, 
and instead you get a "no member for type..." message. That's 
really annoying, but it's more or less necessary because of how 
opDispatch works. I wish we had a better solution.


More information about the Digitalmars-d-announce mailing list