"Dmitry Olshansky"  wrote in message news:[email protected]...
>
>    void main() @safe {
>       char[] msg = "Hello!".dup;
>       char[] msg2 = msg;
>
> void checkEquals(const char[] msg, const char[] msg2) pure > @trusted {
>         assert(msg.length == msg2.length);
>         assert(memcmp(msg.ptr, msg2.ptr, msg.length) == 0);
>       }
>

So you think adding boilerplate will make function more easily verifiable? Time and statistics proven that more LOCs ==> more bugs.

Yes, that function is more easily verifiable for @safety, because any violation _must_ be inside the @trusted function. If the @safe violating helpers were used, main would effectively be @trusted and more lines would need to be reviewed.

Especially highly repetitive patterns, because nobody actually reads them.

If you have highly repetitive patterns, they should be factored out into reusable functions just like always.

Reply via email to