From: Ilya Zakharevich Date: Fri, 11 Apr 1997 22:25:33 +0000 (-0400) Subject: Fix for incorrect overloaded assignment X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9de372454b482d4516b3f3c85b686af8cb18d211;p=p5sagit%2Fp5-mst-13.2.git Fix for incorrect overloaded assignment 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 --- diff --git a/gv.c b/gv.c index cc520d6..257f421 100644 --- a/gv.c +++ b/gv.c @@ -1301,7 +1301,7 @@ int flags; 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)) ); }