On 18/03/12 20:37, Christian Aistleitner wrote: > Dear all, > > should we allow using PHP's assert [1] in MediaWiki code? > > It would allow us to formulate and automatically verify conditions > about code, while at the same time providing readable documentation of > code for free. > > Possible, exemplary use cases would be: > - automatically verifyable documentation of code's intent > - guarding against logic pitfalls like forgetting to set a variable in > all branches of switches, if/else cascades > - guarding against using uninitialized variables > > What do you think?
We use exceptions for that. > P.S.: For typical MediaWiki use cases, PHP's assert is even faster > than throwing exceptions behind 'if'-guards. That's funny, for me "if" is about 10 times faster than assert() in the non-throwing case. Micro-optimisation in PHP usually revolves around minimising the number of function calls, since a function call is relatively complex and expensive compared to other opcodes. -- Tim Starling _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l