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 /regen | |
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 'regen')
-rwxr-xr-x | regen/feature.pl | 9 | ||||
-rwxr-xr-x | regen/keywords.pl | 2 | ||||
-rw-r--r-- | regen/opcodes | 2 | ||||
-rw-r--r-- | regen/warnings.pl | 4 |
4 files changed, 16 insertions, 1 deletions
diff --git a/regen/feature.pl b/regen/feature.pl index efecebbee8..e3eb8e9432 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -35,6 +35,7 @@ my %feature = ( unicode_strings => 'unicode', fc => 'fc', signatures => 'signatures', + isa => 'isa', ); # NOTE: If a feature is ever enabled in a non-contiguous range of Perl @@ -752,6 +753,14 @@ Reference to a Variable> for examples. This feature is available from Perl 5.26 onwards. +=head2 The 'isa' feature + +This allows the use of the C<isa> infix operator, which tests whether the +scalar given by the left operand is an object of the class given by the +right operand. See L<perlop/Class Instance Operator> for more details. + +This feature is available from Perl 5.32 onwards. + =head1 FEATURE BUNDLES It's possible to load multiple features together, using diff --git a/regen/keywords.pl b/regen/keywords.pl index 9619d86faf..ffc4882efa 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -46,6 +46,7 @@ my %feature_kw = ( evalbytes => 'evalbytes', __SUB__ => '__SUB__', fc => 'fc', + isa => 'isa', ); my %pos = map { ($_ => 1) } @{$by_strength{'+'}}; @@ -217,6 +218,7 @@ __END__ -index -int -ioctl +-isa -join -keys -kill diff --git a/regen/opcodes b/regen/opcodes index 4e8236947a..745acbbd04 100644 --- a/regen/opcodes +++ b/regen/opcodes @@ -572,3 +572,5 @@ lvref lvalue ref assignment ck_null d% lvrefslice lvalue ref assignment ck_null d@ lvavref lvalue array reference ck_null d% anonconst anonymous constant ck_null ds1 + +isa derived class test ck_isa s2 diff --git a/regen/warnings.pl b/regen/warnings.pl index 1c58b3ad0e..93e6763344 100644 --- a/regen/warnings.pl +++ b/regen/warnings.pl @@ -16,7 +16,7 @@ # # This script is normally invoked from regen.pl. -$VERSION = '1.45'; +$VERSION = '1.46'; BEGIN { require './regen/regen_lib.pl'; @@ -117,6 +117,8 @@ my $tree = { [ 5.029, DEFAULT_ON ], 'experimental::vlb' => [ 5.029, DEFAULT_ON ], + 'experimental::isa' => + [ 5.031, DEFAULT_ON ], }], 'missing' => [ 5.021, DEFAULT_OFF], |