Dlang + compile-time contracts

Martin Tschierschke via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 1 02:51:55 PDT 2017


On Monday, 31 July 2017 at 17:54:04 UTC, Marco Leise wrote:
> Coming from D.learn where someone asked for some automatism to 
> turn runtime format strings to `format()` into the equivalent 
> `format!()` form automatically to benefit from compile-time 
> type checks I started wondering...
>
> The OP wasn't looking for other benefits of the template 
> version other than argument checking and didn't consider the 
> downsides either. So maybe there is room for improvement using 
> runtime arguments.
>
> So let's add some features:
> 1) compile-time "in" contract, run on the argument list
> 2) functionality to promote runtime arguments to compile-time

This was the more precise question:
How to "promote runtime arguments to compile-time".

I forgot the exact error, but it was during using vibe.d, that 
there
was an error popping up at runtime, which I thought should have 
been detected as simple syntax violation already during compile 
time.

Making me feeling for some seconds being back at .php. :)

I think it was in a regex, where the use of ctRegex would have 
prevented me from
the runtime error.

And last but not least: Thank you Marco for sharing your thoughts 
and expertise!

Regards mt.



More information about the Digitalmars-d mailing list