diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2019-10-23 19:00:38 +0100 |
---|---|---|
committer | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2019-12-09 23:19:05 +0000 |
commit | 813e85a03dc214f719dc8248bda36156897b0757 (patch) | |
tree | 9e3c12a41469a967477219e0d0a670ab593618d2 /proto.h | |
parent | e139e9c0aa8151ab29e98bb9f3216ee7a14abe4d (diff) | |
download | perl-813e85a03dc214f719dc8248bda36156897b0757.tar.gz |
Add the `isa` operator
Adds a new infix operator named `isa`, with the semantics that
$x isa SomeClass
is true if and only if `$x` is a blessed object reference that is either
`SomeClass` directly, or includes the class somewhere in its @ISA
hierarchy. It is false without warning or error for non-references or
non-blessed references.
This operator respects `->isa` method overloading, and is intended to
replace boilerplate code such as
use Scalar::Util 'blessed';
blessed($x) and $x->isa("SomeClass")
Diffstat (limited to 'proto.h')
-rw-r--r-- | proto.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -480,6 +480,11 @@ PERL_CALLCONV OP * Perl_ck_index(pTHX_ OP *o) #define PERL_ARGS_ASSERT_CK_INDEX \ assert(o) +PERL_CALLCONV OP * Perl_ck_isa(pTHX_ OP *o) + __attribute__warn_unused_result__; +#define PERL_ARGS_ASSERT_CK_ISA \ + assert(o) + PERL_CALLCONV OP * Perl_ck_join(pTHX_ OP *o) __attribute__warn_unused_result__; #define PERL_ARGS_ASSERT_CK_JOIN \ @@ -3412,6 +3417,11 @@ PERL_CALLCONV void Perl_sv_insert_flags(pTHX_ SV *const bigstr, const STRLEN off PERL_CALLCONV int Perl_sv_isa(pTHX_ SV* sv, const char *const name); #define PERL_ARGS_ASSERT_SV_ISA \ assert(name) +PERL_CALLCONV bool Perl_sv_isa_sv(pTHX_ SV* sv, SV* namesv) + __attribute__warn_unused_result__; +#define PERL_ARGS_ASSERT_SV_ISA_SV \ + assert(sv); assert(namesv) + PERL_CALLCONV int Perl_sv_isobject(pTHX_ SV* sv); #define PERL_ARGS_ASSERT_SV_ISOBJECT #ifndef NO_MATHOMS |