User forums > Help
NULL undefined
killerbot:
just never use NULL? it is not standard C/C++.
Why would you use it, it is just not professional.
If we want to be stupid and use NULL, well then we can as well use ZERO, now let's hope our compiler 'defines' it for us.
Bweurk, #define, yet another non professional thing ...
oZZ:
I #define nullptr 0 for the time being. It's being added to the C++ standard in the next revision as something different than 0 to give a little more safety to null pointers, so it's probably a better way to do it for now. Just remember to remove the #define when C++0x hits.
wwolf:
--- Quote ---just never use NULL? it is not standard C/C++.
Why would you use it, it is just not professional.
If we want to be stupid and use NULL, well then we can as well use ZERO, now let's hope our compiler 'defines' it for us.
Bweurk, #define, yet another non professional thing ...
--- End quote ---
Please refrain from presenting such (mistaken) opinions as facts. NULL is standard. If you do not believe me, buy the standard. It is 18USD in PDF format and you can also buy it from Wiley and sons in book format. Until you have and understood the standard please refrain yourself from statements based on bad or misunderstood knowledge. You are not only putting a bad light onto yourself (in the eyes of those who really know C++ and have experiences with it) but you also hurt those beginners who believe you.
NULL in C and C++ is standard. It is actually defined in more than one standard header. It is so much standard, that C++0x (the new C++ standard) is going to introduce a special type to represent NULL pointers (of any kind).
Why is NULL important? Simply because it is a name. Of course, we can write 0 in C++. Yes. And we could also work in assembler, and drop C++ completely. But we want to write readable and maintainable code. If we look at the code we want to see immediately if something is a "null pointer constant" or the zero integer. There is no difference between the two for the compiler, but there is a logical, conceptual difference between them on the design level. (That is the reason why nullptr is being introduced into standard C++ - to make the null pointer constant different for the compiler as well, not only for the human reader.)
So, I have to strongly disagree with your assessment on NULL and kindly ask you to think twice before you post such nonsense. You actually hurt people with these kind of statements. If they believe you, they will flank exams, job interviews, develop bad programming practices - and perhaps learn from you making technical statements based on gut feelings instead of knowledge. It might work in politics, but it is not a winning strategy in an engineering discipline. I know, I was there myself. :)
So I am afraid it is not NULL that is not professional, but your post. :( NULL is standard - part of the ISO standard C and also the C++ language; and its use is professional: it makes software more readable, less ambiguous and more maintainable.
TDragon:
--- Quote from: wwolf on September 16, 2007, 03:37:42 am ---NULL is standard. If you do not believe me, buy the standard.
--- End quote ---
In case anyone is wondering:
--- Quote from: ISO/IEC 14882:1998 18.1 - Types ----4- The macro NULL is an implementation-defined C++ null pointer constant in this International Standard (conv.ptr).*
[Footnote: Possible definitions include 0 and 0L, but not (void*)0. --- end foonote]
--- End quote ---
wwolf:
Thanks. I did not want to quote it, because I was not sure that it would convince someone who wrote something like the original post I have replied to. And in case anyone is wondering why do I spend time to write a long post about this... Well, let's just say that I have lost 5 years of my life on fixing crap code just because Mr. Bullschildt wrote a book based on the same kind of "knowledge" demonstrated by the OP, and my company bought that book. Before I started to work for them. It took at least 5 years of hard work to make people unlearn the enormous amount of crap and "applied misunderstanding" they have gathered from the book and from similar "opinionated guesswork" kind of "learning" as was demonstrated by the OP.
In other words: I have seen and suffered the damage that amateur, guesswork based approaches can lead to. I was lucky that my company is huge. Had I have met this level of incompetence in a smaller shop, it would have taken the place down. And when I say incompetence I do not mean people who are ignorant and/or do not want to learn. I mean that people have been taught outright crap by books and by "well meaning" individuals who taught their misunderstandings and lack of knowledge (with lack of experience) as fact.
Software engineering (although we successfully demonstrate many sings of the contrary) is neither a religion, nor fashion, nor politics. Believing and liking/disliking has no place in making technical decisions. Only facts do, and thinking. And that is what I have attempted to promote. Even if I sounded like a j*rk or a smart S. ;)
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version