Rant after trying Rust a bit

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 26 15:53:49 PDT 2015


On Sunday, 26 July 2015 at 19:54:28 UTC, Walter Bright wrote:
> Unit tests are also not exclusively about runtime. Using a unit 
> test to instantiate a template is a compile time test.

Yes, it test the instantiation to some extent. It tests that the 
instantiate works granted you pass it what is expected.

It does not test that the instantiation will fail if you pass it 
anything else, or worse, do random unexpected stuff.

The problem is the exact same as for dynamic typing and unitests. 
A dynamically typed function that expect a string can be test 
exhaustively with warious string passed as arguments. Still, none 
knows what happen when passed an int, float, array, object or 
whatever. Worse, it is either going to blow up in some unexpected 
way or not explode and do random stuff.

The same way, instantiate your template with something it doesn't 
expect and you get absurdly complex errors (and it is getting 
worse as phobos get more and more "enterprise" with Foo 
forwarding to FooImpl and 25 different helpers).

The problem is the same, will it fail at call site/instanciation 
site with "I expected X you gave me Y" or will it fail randomly 
somewhere down the road in some unrelated part of the code, or 
worse, not fail at all when it should have ?



More information about the Digitalmars-d mailing list