Introduce SvCANEXISTDELETE in pp.h, which simplify the logic in pp_helem and pp_hslice
[p5sagit/p5-mst-13.2.git] / pp.h
diff --git a/pp.h b/pp.h
index 6f0f258..118c027 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -500,6 +500,15 @@ True if this op will be the return value of an lvalue subroutine
 =cut */
 #define LVRET ((PL_op->op_private & OPpMAYBE_LVSUB) && is_lvalue_sub())
 
+#define SvCANEXISTDELETE(sv) \
+ (!SvRMAGICAL(sv)            \
+  || ((mg = mg_find((const SV *) sv, PERL_MAGIC_tied))           \
+      && (stash = SvSTASH(SvRV(SvTIED_obj(MUTABLE_SV(sv), mg)))) \
+      && gv_fetchmethod_autoload(stash, "EXISTS", TRUE)          \
+      && gv_fetchmethod_autoload(stash, "DELETE", TRUE)          \
+     )                       \
+  )
+
 /*
  * Local variables:
  * c-indentation-style: bsd