comp.lang.ada
 help / color / mirror / Atom feed
From: Simon Wright <simon@pogner.demon.co.uk>
Subject: Re: Ada vs. C++ (Readability)
Date: 1997/09/10
Date: 1997-09-10T00:00:00+00:00	[thread overview]
Message-ID: <x7v7mcplne6.fsf@pogner.demon.co.uk> (raw)
In-Reply-To: 5v4kie$jp1@panix.com


hymie@panix.com (Hyman Rosen) writes:

> In article <341566c7.0@news.uni-ulm.de>,
> Joerg Rodemann <rodemann@mathematik.uni-ulm.de> 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




  parent reply	other threads:[~1997-09-10  0:00 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-09-09  0:00 Ada vs. C++ (Readability) Joerg Rodemann
1997-09-09  0:00 ` Hyman Rosen
1997-09-10  0:00   ` Joerg Rodemann
1997-09-11  0:00     ` Hyman Rosen
1997-09-10  0:00   ` Simon Wright [this message]
1997-09-11  0:00     ` Robert Dewar
1997-09-11  0:00       ` Hyman Rosen
1997-09-12  0:00         ` Joerg Rodemann
1997-09-15  0:00         ` Richard A. O'Keefe
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox