Re: not_null function

From: Date: Thu, 03 Jul 2014 11:35:52 +0000
Subject: Re: not_null function
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-75219@lists.php.net to get a copy of this message
hi, On Thu, Jul 3, 2014 at 11:40 AM, Xen <xen@dds.nl> wrote: > But a line like "if (!is_null($a))" feels like there are two verbs in it. > > It is like you are saying "if $a is not is null". > > It is different for the "empty" function because there is no "is_" prefix > in > it. So "if (!empty($a)) feels completely sane. > > So generally I will *want* to test a null condition but I just hope my > variable won't contain anything that evaluates to false and just test "if > ($a)". that's why we have is_null, and NULL is a type, not a value btw. also isset is an operator, not a function. (referred in other replies). > If there was a not_null() I would use that instead, because "if > (not_null($a))" only contains one "verb" instead of two. > And I would define that helper function myself, but I don't want to write > code that another person would not be able to run just because not_null is > not defined in his library. is_null is consistent with the other is_* functions. A programming language is not a natural language so grammatical or semantic imperfections are totally valid. between the is_* functions, isset or ?:, I do not see a need to add the exact same features for a non technical reason. Cheers, -- Pierre @pierrejoye | http://www.libgd.org

« previous php.internals (#75219) next »