Re: How to redefine arithmetic operators.



jacob navia <jacob@xxxxxxxxxxxxxxxx> writes:
> Keith Thompson a écrit :
>> You don't really *need* operator overloading; anything you can do
>> with
>> it, you can do without it (with ordinary function calls).
>
> This is of course true.
>
> It is just a matter of measure.
>
> Consider this:
> qfloat a;
> qfloat q = (sqrt(a+1)/sqrt(a-1))*(cos(a+1)/cos(a-1));
>
> compared with:
>
> tmp1 = qadd(a,1);
> tmp2 = sqrtq(tmp1);
> tmp3 = qsub(a,1);
> tmp4 = sqrt(tmp3);
> tmp5 = qdiv(tmp1,tmp3);
> tmp6 = cosq(tmp1);
> tmp7 = cosq(tmp3);
> tmp8 = qdiv(tmp6,tmp7);
> result = qmul(tmp8,tmp5);
>
> This does the *same* stuff but which expression would
> you prefer???

I prefer the one that's valid C, and that I can use on systems other
than Win32.

In the context of this newsgroup (now listen carefully), *C does not
support operator overloading*. Conversely, a language that does
support operator overloading is not C. I've used languages that do
support operator overloading, and I've found it useful when used
carefully -- but those languages have their own newsgroups, as does
the lcc compiler.

And jacob, please don't send me e-mail copies of Usenet followups.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: low sugar - spotty vision
    ... I have never heard of the asynchrony of newsgroup propagation, ... Batch mode newsreaders are still commonplace over ... to compete, most businesses, here in the U.S.A.don't use it. ... Can't remember how many computer languages I've programmed in. ...
    (alt.support.diabetes)
  • Re: low sugar - spotty vision
    ... I have never heard of the asynchrony of newsgroup propagation, ... Batch mode newsreaders are still commonplace over ... to compete, most businesses, here in the U.S.A.don't use it. ... Can't remember how many computer languages I've programmed in. ...
    (alt.support.diabetes)
  • Re: Useful classical inheritance example?
    ... multiple inheritance is just also additional code reuse *sugar* (yeah, ... Comparing programming languages is not ... unless both languages are ECMAScript implementations. ... Your ignoring the topic of this newsgroup does not make these discussions ...
    (comp.lang.javascript)
  • Re: Flamebait if I ever saw it
    ... we have a guy spamming this ... newsgroup with advertisements for his F# and OCaml "expertise", ... Many people wanting to broaden their knowledge of programming languages ... tend to sound highly arbitrary and generally portray F# and OCaml to be ...
    (comp.lang.lisp)
  • Re: Sudden invasion of "Complex Script" fonts?!
    ... Suzanne, the newsgroup language-muncher idea is interesting, but I somehow doubt it's the culprit here. ... I've had this problem with RTL languages and complex fonts for some time and ... when I used the Save My Settings ...
    (microsoft.public.word.newusers)