RE: Brain Death - [PHP] functions classes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Right or wrong - C does not actually have NULL :-)  NULL in C is simply mapped to zero.  It is useful in logic to sometimes use mapping of logical sentence letters to numbers and use mathematics to perform proof, but that is a special case.  

In languages like C, there is no special method of marking a variable as true NULL.  Thus, the language has no way of processing three state logic.  In SQL, there is a special flag to note that variables are truly null and so it can process three state logic.

PHP is odd because it does have a special NULL state but it does not fully support three state logic.  But hey - it is a web scripting language - it would be a shame if PHP got all theoretical on us!

BTW:
>Rome... Oh btw, PHP draws strongly from C, and in C NULL == NULL, and

NULL == NULL === TRUE

It is

NULL === NULL == absurd.

So - my approach:

I may well use is_null() in low traffic areas on PHP, but then when in an inner loop etc, use === null and maybe comment what it means.

Cheers to all

AJ


Alexander J Turner Ph.D.
www.deployview.com
www.nerds-central.blogspot.com
www.project-network.com

-----Original Message-----
From: tedd [mailto:tedd@xxxxxxxxxxxx] 
Sent: 26 August 2006 19:24
To: Robert Cummings; tedd
Cc: Alex Turner; php-general@xxxxxxxxxxxxx
Subject: RE:  Brain Death - [PHP] functions classes

At 2:30 PM -0400 8/26/06, Robert Cummings wrote:
>On Sat, 2006-08-26 at 12:41 -0400, tedd wrote:
>  > At 4:51 PM +0100 8/26/06, Alex Turner wrote:
>>  >And to be very pedantic - as null does not have a type then actually
>  > >'x === null' should evaluate to absurdity, but PHP is more pragmatic
>>  >than that ;-)
>>
>>  That's a very good point.
>>
>>  While one NULL variable in php can be compared to another NULL
>>  variable and produce true, it's not so in MySQL.
>>
>>  In MySQL NULL does not equal NULL -- such comparisons produces NULL
>>  and not true. Instead you have to use IS_NULL or NOT NULL to check
>>  for NULL.
>>
>>  So, it's probably best to get into the habit of using is_null.
>
>I strongly disagree... If I'm writing SQL then I adhere to the language
>constructs of SQL, if I'm coding in PHP then I adhere to the language
>constructs of PHP. There is no reason why one should forgo better
>constructs just because they don't appear in other languages. When in
>Rome... Oh btw, PHP draws strongly from C, and in C NULL == NULL, and
>last I checked C predates SQL.
>
>Cheers,
>Rob.

Rob:

As the old woman who kissed the cow said "To each their own."

My reasoning is simple and I don't strongly agree, or disagree, with 
other methodologies. I write in several languages, such as php, js, 
mySQL, css, and others -- and each have their own constructs. As 
such, I try to use similar constructs where ever possible. My memory 
isn't what it used to be.

Besides, what Alex Turner said about NULL is correct -- it's absurd 
to have NULL evaluate to anything. Just because one language allows 
absurdity doesn't mean you have to practice it.

Your mileage may differ and that's Okay.  :-)

tedd

-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

-- 
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/427 - Release Date: 24/08/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.6/427 - Release Date: 24/08/2006
 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux