Boost logo

Boost :

From: Manfred Doudar (manfred.doudar_at_[hidden])
Date: 2005-06-05 23:22:14


Dave Harris wrote:

>In-Reply-To: <005501c566b3$1fc76eb0$2b792518_at_heronnest>
>cdiggins_at_[hidden] (christopher diggins) wrote (abridged):
>
>>>I strongly disagree. Forcing initialization makes code that is not
>>>useful for high performance numerical processing. When we declare a
>>>container of 1000000 elements, we don't want to waste time
>>>initializing each, unless we want to.
>>>
>>I think the best solution in this case is to use an alternative
>>"collection" for numerical processing. Using a class intended as
>>general purpose array for numerical processing I think would not be a
>>good idea.
>>
>
>I doubt we need a whole class. A special argument might do, to let us
>choose:
>
> boost::array<int,1000> b( boost::uninitialised );
> boost::array<int,1000> b( boost::initialised );
>

That's a reasonable proposition. But for the initialized case, you want
to be specifying a value to initialize to - zero is *not* a reasonable
default for all circumstance.

>
>The question for me is what the default should be. And in my view, the
>default should be safe rather than fast.
>

 From what I gather, and the commentary you make below, I seriously beg
to differ. Back to the year dot with C & C++ we've never had such a
thing as pre-initialization of arrays and it'd be a bad time to start
such a movement now.

Furthermore, for persons like myself writing plenty of numerical code,
and algorithmic development - the default better be the fastest and with
a minimalist take on assumptions - as always ... trust the developer to
know what they are doing.

>
>----
>For what it's worth, I think auto variables, std::complex and even
>std::vector should be the same: initialised by default but with
>uninitialised available as an option. And since this is now a language
>change, perhaps "boost::initialised" should be spelt "?" for brevity.
>
> int x; // x == 0.
> int y = ?; // y is uninitialised.
> int *px = new int; // *px == 0.
> int *py = new int( ? ) // *py is uninitialised.
> vector<int> vx( 100 ); // vx.front() is 0.
> vector<int> vy( 100, ? );
>
>

Please let's not go down this path; and as for vectors, we can opt to
initialize on construction - I can't see the benifit of such a proposal,
but to safeguard against the forgetful.

my $0.02

Cheers,

-- 
Manfred Doudar
MetOcean Engineers
www.metoceanengineers.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk