Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 3.0 Proposed Change: NULL v FALSE
#41

[eluser]Aken[/eluser]
+1, would prefer NULL over FALSE.
#42

[eluser]Tobz[/eluser]
+1 for this.
This way you can tell the difference between if a value exists and is FALSE or does not exist at all.
I've wanted this for ages.
#43

[eluser]InsiteFX[/eluser]
+1 for this Phil, I would rather have it fixed now then to have problems later down the road!
#44

[eluser]Stoney[/eluser]
+1
#45

[eluser]lewebdalex[/eluser]
I do agree, in theory.
That's a good idea ... for new projects.

But, let's face it Phil, I you do ever push that one, you'll come to my office to do a "backward compatibility, search for-replace by, check again if it works" over the thousand lines of code of every controller/model/library I would have written during the last 3 years.

That change is not a minor one. It changes radically one of the foundation of CI, the returning value of core functions.

It's like the day Apple chose on Lion to switch the way the scroll goes, it makes sense, but men, how many of us have turned this crap off ?

#46

[eluser]skunkbad[/eluser]
[quote author="Alexis Serneels" date="1335360115"]I do agree, in theory.
That's a good idea ... for new projects.

But, let's face it Phil, I you do ever push that one, you'll come to my office to do a "backward compatibility, search for-replace by, check again if it works" over the thousand lines of code of every controller/model/library I would have written during the last 3 years.

That change is not a minor one. It changes radically one of the foundation of CI, the returning value of core functions.

It's like the day Apple chose on Lion to switch the way the scroll goes, it makes sense, but men, how many of us have turned this crap off ?

[/quote]

Maybe it could be a setting in config/config:

Code:
$config['null_or_false'] = NULL;
#47

[eluser]CroNiX[/eluser]
I think that's an excellent suggestion, Brian, and it doesn't require much extra processing at all so I hope it's given some weight. A very simple fix that would save developers and their clients hours of unnecessary upgrades and testing. I think anything CI can do to make upgrading code as painless as possible, especially when it doesn't affect speed of CI, should be given as high as of a priority as making the changes themselves. Just note that returning boolean FALSE will be deprecated in the future for these.

If it won't cost a client as much to upgrade, it paints CI in a much better light and makes clients more willing to upgrade. I don't do small simple sites, so any core changes can take a good deal of time and clients aren't willing to upgrade if the benefit isn't justifiable in their mind. This isn't as simple of a change as changing "Controller" to be "CI_Controller".
#48

[eluser]Aken[/eluser]
[quote author="Alexis Serneels" date="1335360115"]I do agree, in theory.
That's a good idea ... for new projects.

But, let's face it Phil, I you do ever push that one, you'll come to my office to do a "backward compatibility, search for-replace by, check again if it works" over the thousand lines of code of every controller/model/library I would have written during the last 3 years.

That change is not a minor one. It changes radically one of the foundation of CI, the returning value of core functions.

It's like the day Apple chose on Lion to switch the way the scroll goes, it makes sense, but men, how many of us have turned this crap off ?

[/quote]
That's why this is a proposition for the next major release of CodeIgniter, not just a random fix for 2.1.x or even 2.2.x. Look at the changes from 1.7.x to 2 - you had to rewrite all of your controllers, models, and then some to use the new CI_ prefix where appropriate.
#49

[eluser]joelkallman[/eluser]
@Aken, I agree that for big releases it is acceptable to create breaking changes within the code. So my question to everybody, if this is worth breaking code for, what are the <b>functional benefits</b> within CodeIgniter (or PHP) that returning NULL will produce? Let me list what I've seen already.

We have (1) simplifying some conditional statements (although it will break others that currently do strict FALSE checks) and (2) simplifying conditional statements for database inserts/updates where you want to pass NULL for a particular field (which requires that that field can store NULL) if it is not found.

Since there are a lot of people who agree with changing FALSE to NULL, I must be missing some areas of CodeIgniter (or PHP) where NULL produces an amazing benefit.

If you'd all be so kind, I'd love to hear your thoughts on the functional benefits of this change.
#50

[eluser]cPage[/eluser]
I agree,

but what the manual say :

Code:
NULL

The special NULL value represents a variable with no value. NULL is the only possible value of type NULL.

A variable is considered to be null if:

it has been assigned the constant NULL.

it has not been set to any value yet.

it has been unset().

Code:
When converting to boolean, the following values are considered FALSE:

the boolean FALSE itself
the integer 0 (zero)
the float 0.0 (zero)
the empty string, and the string "0"
an array with zero elements
an object with zero member variables (PHP 4 only)
[b]the special type NULL (including unset variables)[/b]
SimpleXML objects created from empty tags
Every other value is considered TRUE (including any resource).




Theme © iAndrew 2016 - Forum software by © MyBB