develooper Front page | perl.perl5.porters | Postings from September 2000

Re: Perl5.7.0 "overload" of %{}

Thread Previous | Thread Next
From:
Nick Ing-Simmons
Date:
September 2, 2000 09:49
Subject:
Re: Perl5.7.0 "overload" of %{}
Message ID:
E13VGJL-0001FM-00@roam1
Nick Ing-Simmons <nick@ing-simmons.net> writes:
>
>I am trying to decipher the gv.c code.
>
>Assuming I can find it I suggest:
>
>A. to_hv_amg i.e. %{} and related things do not fall through to 'nomethod'
>
>B. If %{} and co return %_[0] i.e. the object then further looping is 
>   supressed.
>
>(A) should avoid breakage like mine.
>(B) will break out of an easy to do infinite loop and 
>    a way to optimize the "access to self" if you _do_ want the overload.

This is checked in as change 7009 cures the infinite loop and implements (B).
Now to look for (A).

--- pp.h.old    Sat Sep  2 17:46:06 2000
+++ pp.h        Sat Sep  2 17:33:05 2000
@@ -342,10 +342,13 @@
            { dTARGETSTACKED;                                           \
                { dSP; tryAMAGICunW(meth,FORCE_SETs,shift,RETURN);}}}
 
-#define setAGAIN(ref) sv = arg = ref;                                  \
+#define setAGAIN(ref) sv = ref;                                               \   if (!SvROK(ref))                                                     \
       Perl_croak(aTHX_ "Overloaded dereference did not return a reference");  \-  goto am_again;
+  if (ref != arg && SvRV(ref) != SvRV(arg)) {                                 \+      arg = ref;                                                              \+      goto am_again;                                                          \+  }
 
 #define tryAMAGICunDEREF(meth) tryAMAGICunW(meth,setAGAIN,0,(void)0)
                                                       

-- 
Nick Ing-Simmons


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About