comp.lang.ada
 help / color / mirror / Atom feed
From: rodemann@mathematik.uni-ulm.de (Joerg Rodemann)
Subject: Re: Ada vs. C++ (Readability)
Date: 1997/09/10
Date: 1997-09-10T00:00:00+00:00	[thread overview]
Message-ID: <3416458e.0@news.uni-ulm.de> (raw)
In-Reply-To: 5v4kie$jp1@panix.com


Hyman Rosen (hymie@panix.com) wrote:

> In article <341566c7.0@news.uni-ulm.de>,
> Joerg Rodemann <rodemann@mathematik.uni-ulm.de> wrote:
> >  x = 1.00,  0.40,  -1.00;
> >

> 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);

Whoops...seems I messed up the precedence rules. Guess how often I use the
comma operator...?!! Well, many apologies for that here. I should have thought
twice about it.

> The comma operator has been prettily redefined to cause concatenation.

Nevertheless, I can't help to think overloading here is not a good idea if
you want someone else to read this. The only hint that the first two 
numbers are not omitted is that x is of type ray. Sure, once you know what
is meant here it is a neat way for assigning vectors, at least if their
dimension is not very high. I believe overloading is nice when the meaning
of the operator/function is clearly to be guessed from its name or standard
meaning. That is: you provide an abstract operation that has different 
implementations for each type. In this case the actual type is just relevant
to get that function signature right (and the compiler can check that) but
the general meaning should be obvious. IMHO this is not the case for the
example above. 

Another comment, or question, about the expression templates: what about
type safety? I understand that C++ templates are not in any way type safe
wrt the instantion parameters. (E.g. try a list template with a print 
method that calls the type's print method...and instantiate that with an
int or float.) I have not looked at the source of blitz++ nor have I any
deep insights into expression templates at all so this is probably a 
question to the authors? Could you please clarify that?

Sorry for the confusion again,

yours

Joerg

--
rodemann@mathematik.uni-ulm.de | Dipl.-Phys. Joerg S. Rodemann
Phone: ++49-(0)711-5090670     | Flurstrasse 21, D-70372 Stuttgart, Germany
-------------------------------+---------------------------------------------
rodemann@rus.uni-stuttgart.de  | University of Stuttgart, Computing Center
Phone: ++49-(0)711-685-5815    | Visualization Department, Office: 0.304
Fax:   ++49-(0)711-678-7626    | Allmandring 30a, D-70550 Stuttgart, Germany





  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 [this message]
1997-09-11  0:00     ` Hyman Rosen
1997-09-10  0:00   ` Simon Wright
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