Path: utzoo!attcan!uunet!mcvax!enea!kth!draken!Urd!newsuser From: newsuser@LTH.Se (LTH network news server) Newsgroups: comp.lang.c++ Subject: Re: C++ : A free lunch ? Message-ID: <1988Oct31.120012.162@LTH.Se> Date: 31 Oct 88 11:00:12 GMT References: <4165@tekgvs.GVS.TEK.COM> <4762@polya.Stanford.EDU> Reply-To: dag@Control.LTH.Se (Dag Bruck) Organization: Dept. of Automatic Control, Lund Inst. of Technology, Sweden Lines: 33 In article <4762@polya.Stanford.EDU> shap@polya.Stanford.EDU (Jonathan S. Shapiro) writes: >I am a more than competent LISP and SmallTalk hacker Furthermore, Jonathan Shapiro is probably a more than competent C++ hacker. Unless you know perfectly what you are doing, you may for example initialize variables twice. The ``error'' I typically do is as follows: In a class constructor I initialize members by assigning values to them. The problem is that some members are class objects with constructors; these objects are first automatically initialized with default values, which are then thrown away because I make the assignments. >C++ is just as fast as C. Anything you want to do in C++ generates >code that is no more complicated than the equivalent C code would need >to be to do the same job. My C++ generates a fair number of temporary variables in the C code it produces. I understand that these temps are required to guarantee the semantics of C++, but unfortunately, my C compiler on the Sun can't eliminate the redundant assignments. I also suffer some space overhead. Looking at the generated assembler code, I believe it would be safe to remove some instructions, but I don't bother. My general, unscientific, impression is that you may loose about 5% in execution speed when you make a quick port from C to C++. Dag Bruck -- Department of Automatic Control Internet: dag@control.lth.se Lund Institute of Technology UUCP: ...!enea!control.lth.se!dag P. O. Box 118 S-221 00 Lund, SWEDEN Phone: +46 46-108779