Re: operators similar to functions?



jacob navia <jacob@xxxxxxxxxx> writes:
[...]
Since basically there is no difference between operator usage
and a function call, there are heretics that propose to use the
simpler operator notation instead of the function call notation
to call functions.

Those heretics (that are looked upon with disdain by the law-abiding
regulars of this group) propose a sin called "operator overloading"
where you can use the operator notation to call your own functions,
imagine that.

You write this absolutely heretical notation:

result_type operator+(arg_type a,arg_type b);

Then, with suitable definitions of arg_type, the compiler will call
this function instead of doing a normal addition.
[...]

This talk of "heresy" is, of course, complete and utter nonsense.

Operator overloading is neither heretical nor sinful. C is not a
religion. Code that uses features that are not part of standard C is
not sinful, or bad, or even necessarily wrong, it's merely something
other than C.

Ironically enough, operator overloading is actually relevant to the
original poster's question. It's a very nice illustation of how
operators and functions *can* be very similar, and of the fact that
the distinction is more syntactic than semantic (though are are also
some semantic differences). It's a pity that jacob couldn't have made
that point without descending into his usual self-pitying nonsense.

--
Keith Thompson (The_Other_Keith) <kst-u@xxxxxxx>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.



Relevant Pages

  • Re: operators similar to functions?
    ... jacob navia wrote: ... simpler operator notation instead of the function call notation ... Those heretics (that are looked upon with disdain by the law-abiding ... What they _do_ have is a problem with people trying to discuss it in a C programming group, ...
    (comp.lang.c)
  • Re: operators similar to functions?
    ... simpler operator notation instead of the function call notation ... Those heretics (that are looked upon with disdain by the ... and have no problem with this approach - when programming in C++. ... Posted via a free Usenet account from http://www.teranews.com ...
    (comp.lang.c)
  • Re: operators similar to functions?
    ... important reasons for having operands, ... Those heretics (that are looked upon with disdain by the law-abiding ... where you can use the operator notation to call your own functions, ... jacob at jacob point remcomp point fr ...
    (comp.lang.c)