<?xml version="1.0" encoding="windows-1252"?>
<node id="221678" title="Re: Re: Re^3: $bad_names eq $bad_design" created="2002-12-21 17:21:15" updated="2005-07-27 17:36:23">
<type id="11">
note</type>
<author id="108447">
demerphq</author>
<data>
<field name="doctext">
&lt;em&gt;I'm not yet sure which operators perls overloading can handle&lt;/em&gt;&lt;p&gt;
AFAIK All of them. Even the handling of different quoting types in the code.&lt;p&gt;
Its a fallback system however. If the operator is explicitly defined then that definition is used, otherwise if overload can syntheisze the behaviour of the opertor in question by using a different defined operator then it will do so.  For instance defining '&lt;=&gt;' and 'cmp' with the normal settings (the fallback behaviour is configurable) iirc will cause all of the equivelency operators, numeric and string, behavior to be overriden.&lt;p&gt;
One thing you have to watch out for however is the common debugging habit of stringifying references by concatenation. The "" operator can cause some suprising results.&lt;p&gt;
A fairly common use of overload might be
&lt;code&gt;
use overload qw("" stringify
                &lt;=&gt; num_comparision
                cmp str_comparison);
&lt;/code&gt;
When the right hand side is a string as it is in this case then the handler is expected to be a method of that name called against the object. Otherwise a coderef is expected.&lt;p&gt;
The overload docs were written by a mathematician which is why they are relatively incomprehensible to mere mortals like us. Its incredibly easy to miss details or become confused when reading that document. I think I've read it at least ten times and I still find things I haven't seen before.
&lt;P&gt;
--- demerphq&lt;br&gt;
my friends call me, usually because I'm late....&lt;br&gt;
</field>
<field name="root_node">
221498</field>
<field name="parent_node">
221622</field>
</data>
</node>
