From 3731699988551253717
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7b33df5790e7ad92
X-Google-Attributes: gidf78e5,public
From: hinnant@_anti-spam_lightlink.com (Howard Hinnant)
Subject: Re: complex design flaw (#1)
Date: 1999/03/16
Message-ID: <hinnant-1503991945450001@isdn4-13.lightlink.com>#1/1
X-Deja-AN: 455508957
Approved: Fergus Henderson <fjh@cs.mu.oz.au>
References: <x88pv6fok3r.fsf@nbeckerpc.hns.com> <xaj3e3be4pu.fsf@korrigan.inria.fr> <01be6cf4$9f3dcc80$7d9cd4c7@danielp.interlog.com> <xaj7lslx75y.fsf@korrigan.inria.fr> <36EC0E2F.C317A434@wizard.net> <xaj1zirszf9.fsf@korrigan.inria.fr>
X-Original-Date: Mon, 15 Mar 1999 19:45:45 -0500
X-Complaints-To: news@news.unimelb.edu.au
X-Trace: izvestia.its.unimelb.edu.au 921560839 4924 128.250.29.16 (16 Mar 1999 05:07:19 GMT)
Organization: Lightlink Internet
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBFAgUANu3m8+EDnX0m9pzZAQGRVgF/XHtZysl0MHlL40ojLp0ZB9VnguVR5W3i /Kvb6PqcoXi5ouvyGDzzVhuhIQ2R/OuO =Rq5z
NNTP-Posting-Date: 16 Mar 1999 05:07:19 GMT
Newsgroups: comp.std.c++

In article <xaj1zirszf9.fsf@korrigan.inria.fr>, Gabriel Dos_Reis
<gdosreis@korrigan.inria.fr> wrote:

> Fair enough. But, if C++ were to be designed from scratch, I for one,
> would advocate for zero-initilisation of objects of fundamental types
> when declared without initializers. 

Well, I guess it's time to add my $0.02:

I hardily disagree with zero-initialization of fundamental types.  It goes
against the grain of C/C++.  If I want zero-initialized stuff, there is an
easy way to get it with the current design.  But if we turned on the
automatic transmission, it would not be convenient to get
non-zero-initialized stuff when we needed that performance edge.

And since I've dragged myself into this one.  I must agree with the
original poster:  complex default constructor should leave stuff
uninitialized:

template<class T>
class complex
{
public:
   complex() {}
   complex(const T& re, const T& im = T()) : re_(re), im_(im) {}
....
};

If you want zero-initialized stuff, then it is easy enough to say
complex<double>(0), or vector<complex<double> >(100, complex<double>(0)).

I don't see this as a major desgin flaw, just irritating.

I can always build automatic transmissions out of well designed,
efficient, fundamental building blocks.  But it is much more difficult to
extract performance from a pre-packaged notion of someone else's
"convenience package".

Along the same train of thought, I'd of much preferred double() to mean
uninitialized than double(0).  That way I could easily choose the right
model for my vector<double>.  But that's water under the bridge now...

-Howard
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]



