On Friday, 8 February 2013 at 11:25:07 UTC, monarch_dodra wrote:
"in" and "out" contracts themselves are flawed in D in any case, given they are part of the "called" code, as opposed to "caller" code.

This makes them absolutely no different than an assert.

The problem is that an assert is "internal" validation, whereas an "in"/"out" is supposed to be a handshake between the caller/callee.

Isn't it exactly how contracts are supposed to work? They are neither error handling tools, nor handshake - more like tools to verify interconnections between different inner parts of program stay sane. For example, in web application you would like to escape user input only once, upon receiving it, and it makes sense to not waste cycles on verifying it is actually escaped down the code path. But adding a contract to make sure someone does not use that library function on a raw input by accident - makes perfect sense. Of course, contracts shine only if some debug-mode testing is in place during development process but right now they do behave in D exactly how I would have supposed.

Reply via email to