On 31/07/13 18:36, Daniel Kinzler wrote:
> Assertions are things that should *always* be true.
> In my mind, assertions should just throw an (usually unhandled)Indeed. In C, assert() will abort the program if it is enabled, which
> exception, like Java's AssertionError.
is hard to miss. It is not comparable to the PHP assert() function.
The reasons I don't like assert() are:
> I don't really see how the resulting boiler plate would be cleaner
> or safer:
>
> if ( $foo > $bar ) { throw new OMGWTFError(); }
1. It doesn't throw an exception
2. It acts like eval()
We could have a library of PHPUnit-style assertion functions which
throw exceptions and don't act like eval(), I would be fine with that.
Maybe MWAssert::greaterThan( $foo, $bar ) or something.
-- Tim Starling
_______________________________________________
Wikidata-tech mailing list
Wikidata-tech@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-tech