On 11/1/2014 4:31 AM, bearophile wrote:
His language seems to disallow comparisons of different types:void main() { int x = 10; assert(x == 10.0); // Refused. }
More than that, he disallows mixing different integer types, even if no truncation would occur.
I like the part about compile-time tests for printf: http://youtu.be/UTqZNujQOlA?t=38m6s
Unnecessary with D because writeln checks it all. Even so, if printf were a template function, D can also check these things at compile time.
The same strategy is used to validate game data statically: http://youtu.be/UTqZNujQOlA?t=55m12s
D allows extensive use of compile time validation.
He writes a function that is called to verify at compile-time the arguments of another function. This does the same I am asking for a "static precondition", but it has some disadvantages and advantages. One advantage is that the testing function doesn't need to be in the same module as the function, unlike static enums. So you can have the function compiled (separated compilation). Perhaps it's time for DIP.
D can run arbitrary functions at compile time even if they are in different files.
