Mailing List Archive

Re: perl5.002 / SUPER - the fix.
In <9511221825.AA02650@pluto>
On Wed, 22 Nov 95 18:25:18 GMT
Nick Ing-Simmons <Nick.Ing-Simmons@tiuk.ti.com> writes:
>
>My patch to gv.c (and hence 5.002) has :
>
> if (strEQ(origname,"SUPER")) {
> /* Degenerate case ->SUPER::method should really lookup in original stash */
> SV *tmpstr = sv_2mortal(newSVpv(HvNAME(stash),0));
> ^^^^^^^^^^^^^
> sv_catpvn(tmpstr, "::SUPER", 7);
> stash = gv_stashpv(SvPV(tmpstr,na),TRUE);
> *nsplit = ch;
> DEBUG_o( deb("Treating %s as %s::%s\n",origname,HvNAME(stash),name) );
>
>I think 1st HvNAME(stash) should really be caller's package name,
>but I don't know how to get that from C (yet) ...

It is of course as in this patch relative to 5.002:

*** gv.1.c Wed Nov 22 18:27:24 1995
--- gv.c Wed Nov 22 18:28:14 1995
***************
*** 225,231 ****
*nsplit = '\0';
if (strEQ(origname,"SUPER")) {
/* Degenerate case ->SUPER::method should really lookup in original stash */
! SV *tmpstr = sv_2mortal(newSVpv(HvNAME(stash),0));
sv_catpvn(tmpstr, "::SUPER", 7);
stash = gv_stashpv(SvPV(tmpstr,na),TRUE);
*nsplit = ch;
--- 225,231 ----
*nsplit = '\0';
if (strEQ(origname,"SUPER")) {
/* Degenerate case ->SUPER::method should really lookup in original stash */
! SV *tmpstr = sv_2mortal(newSVpv(HvNAME(curcop->cop_stash),0));
sv_catpvn(tmpstr, "::SUPER", 7);
stash = gv_stashpv(SvPV(tmpstr,na),TRUE);
*nsplit = ch;
Re: perl5.002 / SUPER - the fix. [ In reply to ]
We will need to carefully document the fact that the SUPER:: prefix is
only useful within the class. Outside the class, it would have to be
fully qualified as $obj->derived::SUPER::amethod. I wonder if there's
any way of catching or warning about that error.

Hmm, I also wonder how moreso::SUPER::SUPER::meth would behave.

Larry