On 6/16/13, Tyler Romeo tylerromeo@gmail.com wrote:
So I was wondering how people would feel about adding a coding convention for the use of is_null() in PHP code.
It's 10 times slower than doing === null, which is a bit trivial in context, but nonetheless a fact, and it's also a bit easier to read, especially when doing the inverse (i.e., doing !is_null( ... ) versus !== null). Also, there's no functional difference between the two.
Any objections other than maintaining the status quo?
*-- * *Tyler Romeo* Stevens Institute of Technology, Class of 2016 Major in Computer Science www.whizkidztech.com | tylerromeo@gmail.com _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Easier to read is debatable. !is_null( $foo ) reads directly like an english sentence "Not is null". Ok, maybe an english sentence with bad grammar, but I hardly find it unclear.
As for performance. 10x out of context doesn't mean much (How much slower is 10x. If we changed all 681 instances to the other one, are we talking about a difference of 1 microsecond in absolute time? Or is 10x an actually significant saving. For that matter is the benchmark being used actually reliable?)
I feel such trivialities should be left at the discretion of the commiter
--bawolff