From -7767653785562572746
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,2340bb60e0f0f248
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2002-02-15 08:48:02 PST
Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!dispose.news.demon.net!news.demon.co.uk!demon!mail2news.demon.co.uk!not-for-mail
From: Markus Werle <numerical.simulation@web.de>
Newsgroups: comp.std.c++
Subject: Re: proposal for resolution of "valarray operator[] const returning value" (closed isuue 77)
Date: Fri, 15 Feb 2002 16:47:36 GMT
Organization: Aachen University of Technology (RWTH)
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Message-ID: <a4ijua$hij$1@nets3.rz.RWTH-Aachen.DE>
References: <a4goca$5ln$1@nets3.rz.RWTH-Aachen.DE> <flwuxg0z6l.fsf@jambon.cmla.ens-cachan.fr>
X-Trace: mail2news.demon.co.uk 1013791668 mail2news:19644 mail2news mail2news.demon.co.uk
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7Bit
NNTP-Posting-Date: 15 Feb 2002 09:21:14 GMT
User-Agent: KNode/0.6.1
Lines: 61
Xref: archiver1.google.com comp.std.c++:9660

Gabriel Dos Reis wrote:

> More importantly, it makes valarray<> unusable in most real world
> programs.  There are plenty of numerical routines out there written in
> C and passing valarray<> data to them for inspection is not as trivial
> as it should have been or intented :-(
> 
> FYI, the GCC/g++ changed that operator to return a const reference.

Yes, I fell into the trap when gcc-compliant code did
not compile with intel's C++.
IMHO this is the wrong way to go either. I dislike the freedom
gcc developers took without noticing me in the README. 
ISO conformance is a must, so we must change the standard if it 
does not fit, not our "private" library.

> | I for myself can think of a lot of cases in which I wished
> | to have all the functionality of valarray, but a return type of
> | const reference, (e.g. valarray<map<size_t, double> > for
> | compressed matrices)
> | and so I propose an extension of valarray which
> | I think does not break existing, conformant code.
> 
> I have trouble to conceive a real-world program which would be broken
> if that operator's return type were changed to const reference.  So
> let keep it simple and straight.

I disagree here. Both ways have their pros and cons
and if You are honest they balance quite well.
Those who struggle with connection to fortran and C
need the reference (which speeds code by a factor of 10 or more)
and those who have a Pentium 4 and the intel compiler 
need the copy (sometimes), because this may speed up 
by a factor of 10 or more due to funny register magic 
I do not want to learn about.

Again: both positions are right in some case and 
wrong in some others. Face it.

My approach is to be fair: the solution is easy to 
achieve, does not strike the innocent and gives
Scott Meyers the opportunity to add the valarray
chapter he forgot in "Effective STL".

Let us stop a never ending fruitless
discussion with a quite elegant whip.

Have You any argument against my approach?
Let me hear. If not, vote for it and stop insisting 
on the const reference. You are right and You get what 
You want while others may have their copy, too.


Markus

---
[ 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://www.research.att.com/~austern/csc/faq.html                ]



