On 14/09/2006, at 1:02 PM, Malcolm V wrote:
Using '+' to sum matrices (or any identical mathematical types) is
in no
way what I would consider an example of overloading.
Sorry, the rest of the world would disagree with you here. You're
defining your own function/operator named + that can work on
matrices, as opposed to a version of + that will work with other
types (e.g. integers or floats.) That's ad-hoc polymorphism, also
called overloading. See Wikipedia's definitions of overloading and
operator overloading for more information:
http://en.wikipedia.org/wiki/Polymorphism_(computer_science)
#Overloading
http://en.wikipedia.org/wiki/Operator_overloading
Function name overloading is a good thing. It means that you can a
function named foobar which can carry out the foobar operation on
more than one type of operand:
void foobar (int i) ;
void foobar (float f) ;
makes far more sense than:
void foobar_i (int i) ;
void foobar_f (float f) ;
especially as the number of different operand types increases. In
this particular example, the compiler should figure out that
foobar (my_int) ;
and
foobar (my_float) ;
are two different functions.
Sure, the compiler can figure that out. What it can't figure out is
when
you accidently pass the wrong operand type to foobar, because the
various foobars are quite happy to accept a range of different types.
I'm not sure what you mean by "various foobars are quite happy to
accept a range of different types". Do you have an example?
As a side note, the difficulties/pitfalls of using an interpreter
instead of a compiler should start to become apparent.
Again, I'm not sure what you mean here, sorry. Do you have an
example for this?
--
% Andre Pang : trust.in.love.to.save <http://www.algorithm.com.au/>
_______________________________________________
coders mailing list
[email protected]
http://lists.slug.org.au/listinfo/coders