Subject: Re: overloading problem
Jarkko Hietaniemi writes:
>
>
> Please proofread for me. Isn't what Chris is trying to do
>
> to get overloading to promote the unblessed scalar $c
> containing '2' to a Math::Complex blessed object?
>
> Please correct me if I am wrong but isn't this impossible?
>
> As there are only three possibilities for binops: normally ordered
> arguments, inverted arguments, modifying binop: the overloading will
> swap the honest Math::Complex $z as the first argument _and_ pass the
> third argument to minus() as undef (perldoc overload) and therefore
>
> a) the value of the result will be $z - $c, not $c - $z
> b) minus() will modify $z, not $c
>
> I may just too sleepy...
Looks like an overeager optimization... Try this:
p5p-msgid:
199704112225.SAA03482@monk.mps.ohio-state.edu
EXTEND(sp, notfound + 5);
PUSHs(lr>0? right: left);
PUSHs(lr>0? left: right);
- PUSHs( assign ? &sv_undef : (lr>0? &sv_yes: &sv_no));
+ PUSHs( lr > 0 ? &sv_yes : ( assign ? &sv_undef : &sv_no ));
if (notfound) {
PUSHs( sv_2mortal(newSVpv((char *)AMG_names[method + assignshift],0)) );
}