Re: operator overloading

On man, 2003-04-28 at 18:36, muppet wrote:
is there anybody on the list who is familiar with perl's operator overloading

i tried adding

  package G::Object;
  use overload '==' => \&G::Object::eq;

to[1], so that we could use a natural syntax for comparing object
instances.  (you can't just compare the scalars, because they are always
different; you need to compare the juicy blessed reference value centers

You need to add fallback => 1, so you'd get.
        use overload '==' => \&G::Object::eq, fallback => 1;

This statement should work (that being said - overloading can be
somewhat strange).

Without fallback overload assumes that you have defined all applicable


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]