On Fri, 24 Jul 2009, Bolhar-Nordenkampf Ferdinand wrote:
> > Thus, in any place where I receive a value of which I don't know the
> > origin, I should call SvGETMAGIC first. I could then just as well
> > have
> >
> >   BOOL sv_isdefined(SV *sv) {
> >      SvGETMAGIC(sv);
> >      return SvOK(sv);
> >   }
> >
> > Or would this lead in my new problems?
> >
> > Thanks a lot for your quick answer!
> 
> If a scalar has a type of MAGIC:
> 
> (SvTYPE(sv) == SVt_PVMG) and
> 
> has the SVs_GMG flag set in its SvFLAGS field:
> 
> ((SvFLAGS(sv) & SVs_GMG)
> 
> you should invoke SvGETMAGIC. Otherwise, it isn't required.

That doesn't make much sense; you would just duplicate the SvFLAGS test.
SvGETMAGIC(sv) already expands to

    if (SvFLAGS(sv) & SVs_GMG)
        mg_get(sv);

Likewise there is no point in checking SvTYPE(sv) because only
SVs with attached magic should have the SVs_GMG set.

Cheers,
-Jan

Reply via email to