Re: RE : VC++6.0 and 7.0 are not supported anymore from ROOT4-04-2 or newer

From: <WLavrijsen_at_lbl.gov>
Date: Thu, 12 May 2005 09:17:02 -0700 (PDT)


Hello,

> I understand some of your points. Myself, I am not a fan
> of the "modern" cast syntax because, as you say, it makes
> the code opaque to most readers and the pretext that you have
> more type safety is just an illusion.

If D derives from B, and Func() returns a B*, then:

 D* d = (D*)Func();

will translate into a reinterpret_cast (i.e. no pointer offsets) if both B and D are forward declared, but in a static_cast if D is defined. The former case will lead to memory corruption if B has data members.

Instead,

 D* d = static_cast< D* >( Func() );

will result in an error if D is only known by forward declaration. I.e., no chance of memory corruption. Seen it happen in code I had to maintain.

> We have started using templates internally where we believe that we have
> more to gain than to loose.

Even Java has turned around with generics in Java 1.5.

> We are not in 1992! [..] Young programers could not understand!

Well, I was in high school in 1992. :) The point I'd like to make, is that it is very hard to know what can, and what can not be used if you picked up C++ later than in, say, 1992. People who've been dealing with C++ since that time know what is generally supported by most versions of compilers. People who joined later learn the standard, pick up the latest of the greatest, and simply do not have the working knowledge of which parts to shy away from to get maximum portability across outmoded compilers they have no acccess to (it is not as if MS is still selling VC++6, or that installing and using gcc2.7 on a modern Linux distro is hassle free).

> Anyhow, we welcome comments like yours. It would be good if
> more people could express their opinion.

Well, I think static type safety is overvalued. However, the problem with C++ is that its dynamic type safety is epsilon. New-style casts and templates do help static type safety, and since that is all the type safety that C++ has to offer, might as well use it.

Best regards,

           Wim

-- 
Wim.Lavrijsen_at_cern.ch   --   WLavrijsen_at_lbl.gov   --   www.lavrijsen.net

"Stop making excuses for your software."    --first step towards quality
Received on Thu May 12 2005 - 18:17:23 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET