Jeff Abrahamson on Fri, 26 Jul 2002 11:54:19 -0400


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

Re: The debugger and overloading

  • From: Jeff Abrahamson <jeff@purple.com>
  • To: phl@lists.pm.org
  • Subject: Re: The debugger and overloading
  • Date: Fri, 26 Jul 2002 17:42:47 +0200
  • >received: from diderot.purple.com (diderot [127.0.0.1]) by diderot.purple.com (8.12.3/8.12.3/Debian -4) with ESMTP id g6QFglO3009696 for <phl@lists.pm.org>; Fri, 26 Jul 2002 17:42:47 +0200
  • Mail-followup-to: phl@lists.pm.org
  • Reply-to: phl@lists.pm.org
  • Sender: owner-phl@lists.pm.org
  • User-agent: Mutt/1.3.28i

On Fri, Jul 26, 2002 at 10:55:32AM -0400, Eric Roode wrote:
> If anyone can shed some light on this, I'd be grateful. TIA.
> 
> I have a class, DBdate.  It overloads no operators.  I can go into the 
> debugger, create a new object ("$a = new DBdate('2002-07-26')"), and
> examine the object ("x $a").  Fine.
> 
> Now I edit the module file DBdate.pm.  I add the following lines, no
> others:
> 
> use overload '>'   => '_gt',
>              '>='  => '_ge',
>              '<'   => '_lt',
>              '<='  => '_le',
>              '<=>' => '_cmp',
>              '=='  => '_eq',
>              '!='  => '_ne';
> 
> (Those subroutines already exist in the file).  Now I go into the
> debugger, create a new object the same way, and try to examine it.
> I get:
> 
> Operation `""': no method found, argument in overloaded package DBdate
> at /usr/local/lib/perl5/5.6.1/overload.pm line 92.
> 
> WTH?  I'm not attempting to overload '""'.  I can't believe that
> overloaded objects can't be examined in the debugger...??
> 
> What am I missing?

I believe you have to point to references to functions, not strings:

    use overload '>'   => \&_gt,
		 '>='  => \&_ge,
		 '<'   => \&_lt,
		 '<='  => \&_le,
		 '<=>' => \&_cmp,
		 '=='  => \&_eq,
		 '!='  => \&_ne;

-- 
 Jeff

 Jeff Abrahamson  <http://www.purple.com/jeff/>

 The Big Book of Misunderstanding, now in bookstores and on the web:
 <http://www.misunderstanding.net/buystuff.html>

**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**