From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,65cf1c5c90ed694 X-Google-Attributes: gid103376,public From: Simon Wright Subject: Re: Ada vs. C++ (Readability) Date: 1997/09/10 Message-ID: #1/1 X-Deja-AN: 271205525 X-NNTP-Posting-Host: pogner.demon.co.uk [158.152.70.98] References: <341566c7.0@news.uni-ulm.de> <5v4kie$jp1@panix.com> Organization: At Home Newsgroups: comp.lang.ada Date: 1997-09-10T00:00:00+00:00 List-Id: hymie@panix.com (Hyman Rosen) writes: > In article <341566c7.0@news.uni-ulm.de>, > Joerg Rodemann wrote: > >However, looking at some examples I was suddenly struck by frustration: > >There was some code, that obviously could not work!!! At least that's what > >it looked like. Or how would you interpret the lines: > > ray x, n; > > > > x = 1.00, 0.40, -1.00; > > n = 0.31, 0.20, 0.93; > > > >Surely at first glance whatever type x and n will be, x will be assigned > >the value 1.00, n will be assigned 0.31. The remaining expression is not > >relevant at all from the definition of the colon operator!!! > > Well, I would interpret the lines the way they look - assigning a three > element vector to each of the variables. Do you somehow find this to be > unreadable? It looks straightforward to me! > > The implementation is cute, of course. You forgot that assignment has > lower precedence than comma. In function syntax, those lines become > > x.operator=(1.00).operator,(0.40).operator,(-1.00); > n.operator=(0.31).operator,(0.20).operator,(0.93); > > The comma operator has been prettily redefined to cause concatenation. This view of life is _exactly_ why I deprecate the use of C++ at our shop (there are of course all too many reasons relating to the availability of libraries/programmers/tools why it's a hard struggle). Compare for (int i = 1, int j = 2; .. with for (ray x = 1, 2, 3, int j = 2; .. If you could do it using braces it would be much better: x = {1.00, 0.40, -1.00}; To redefine "," like this is "clever"/"cute" but not "pretty"; certainly not from the view of the maintainer, and we spend a _lot_ of our customers' money maintaining code. I was about to suggest that maybe "<<" would be a less confusing operator to redefine, but I suppose that that's only because all C++ programmers already _know_ that "<<" bas been botched about .. -- Simon Wright Work Email: simon.j.wright@gecm.com GEC-Marconi Radar & Defence Systems Voice: +44(0)1705-701778 Command & Information Systems Divsion FAX: +44(0)1705-701800