Author Topic: NULL undefined  (Read 24467 times)

Offline wwolf

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: NULL undefined
« Reply #30 on: September 22, 2007, 05:19:54 am »
Well, you know, everybody is good for something. If nothing else, one can serve as a bad example.

BTW if you had paid attention to a bit more than the (impossible to get from writing) emotions, and concentrated on meaning instead of (imagined) motivation, you would have seen that my references to those people were merely serving the purpose of showing that I know what I am talking about. Since it seemed that it was not a widely held view. :>

And if you carefully read my posts you will not find any place where I had asked anyone to look at me.  None of the posters here deserved that harsh punishment.  BTW you are the first one in my whole life who have called me a poser.  So you are either a genius who can see what nobody else can, or you are plain wrong. ;)  I can live with either. :>

Attila a.k.a. WW

Offline insolence

  • Single posting newcomer
  • *
  • Posts: 6
Re: NULL undefined
« Reply #31 on: September 22, 2007, 07:15:50 am »
Certainly whether or not NULL is defined is something that can be clarified by looking at the latest published standards.

But separate from this issue I would say that beginners should not be discouraged nor perhaps encouraged from using NULL or macros or anything else.

Admittedly I come from a C, not a C++ background, but its more important that your code be readable and understandable to you and those maintaining it, then that you adhere slavishly to one prominent programmer or another's advice.  If you use macros or NULL to do this, there's nothing wrong with that.

"gotos" in C are considered generally very ugly as they create code that is difficult to debug.  But there is STILL a use for them.  (C++ has try and catch to serve part of this need.)  But what I think should be most clear from this debate is that different people have different coding styles and a beginner must find their own.

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: NULL undefined
« Reply #32 on: September 28, 2007, 11:54:51 am »
If I recall correctly, they are thinking about a *template* for something like nullptr, but I am not sure.
You're going to laugh... for some reason, I woke up this morning and had an implementation of nullptr in my mind.
It works exactly like it should, and it is so ridiculously easy that I just had to put it into prep.h :)
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: NULL undefined
« Reply #33 on: September 28, 2007, 11:59:11 am »
Ok, forgot about multiple definitions... will fix in a minute. :)

EDIT:
With the header being included a thousand times, it gets slightly more complicated, i.e. a .cpp file and an extern declaration are needed, but... it works :)


As a sidenote, doing a global file search for NULL, I noticed that NULL in Code::Blocks occurs in a lot of places where it is actually useless in my opinion, such as in all manager classes:
EditorColourSet* GetColourSet(){ return (this==NULL) ? 0 : m_Theme; }

Unless I have a gross misunderstanding, this cannot possibly be NULL, as all managers are singleton classes. Even if there was the possibility of calling a non-static member function on an uninitialised object, then this would not necessarily be NULL either (but some random, uninitialised value).
« Last Edit: September 28, 2007, 01:00:17 pm by thomas »
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5215
Re: NULL undefined
« Reply #34 on: September 28, 2007, 03:32:03 pm »
@Thomas, don't forget to adjust both Cb cbp's and makefile.am for the added nullptr.cpp file

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: NULL undefined
« Reply #35 on: September 28, 2007, 04:04:43 pm »
Right, thank you... forgot the makefile as usual.   8)
Funnily, the project files aren't committed either, thought I had done that.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."