operator overloading



is there anybody on the list who is familiar with perl's operator overloading
interface?

i tried adding

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

to G.pm[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
inside.)


but when i do this, my test script (panes.pl, another piece of gtk-demo, in
which you need to see if a child widget is the same as another) fails to
compile with this message:

  Operation `bool': no method found, argument in overloaded package
Gtk2::Window at panes.pl line 112.

line 112 looks like this:

      $window->set_title ("Panes");

wtf?!?!  is it trying to test the validity of $window or something?

the overload manpage says that if you supply a spaceship operator, the missing
comparisons are filled in for you, but this doesn't work either.



[1] i tried the XS interface first, and got the same behavior.

-- 
muppet <scott at asofyet dot org>





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