diff options
author | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2022-12-24 13:17:47 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <leonerd@leonerd.org.uk> | 2023-02-10 12:07:02 +0000 |
commit | 99b497aa90ed7db99d29a301b47c91fba65c9cb3 (patch) | |
tree | 09e231f3a6838cdb2df9db9454981b9205046ba1 /regen | |
parent | b40895ae558e0aff0c347785dafeaaff40a01801 (diff) | |
download | perl-99b497aa90ed7db99d29a301b47c91fba65c9cb3.tar.gz |
Initial attack at basic 'class' feature
Adds a new experimental warning, feature, keywords and enough parsing to
implement basic classes with an empty `new` constructor method.
Inject a $self lexical into method bodies; populate it with the object instance, suitably shifted
Creates a new OP_METHSTART opcode to perform method setup
Define an aux flag to remark which stashes are classes
Basic implementation of fields.
Basic anonymous methods.
Diffstat (limited to 'regen')
-rwxr-xr-x | regen/feature.pl | 14 | ||||
-rwxr-xr-x | regen/keywords.pl | 8 | ||||
-rw-r--r-- | regen/opcodes | 2 | ||||
-rw-r--r-- | regen/warnings.pl | 4 |
4 files changed, 26 insertions, 2 deletions
diff --git a/regen/feature.pl b/regen/feature.pl index e06fe281d9..32ae36cc83 100755 --- a/regen/feature.pl +++ b/regen/feature.pl @@ -45,6 +45,7 @@ my %feature = ( defer => 'defer', extra_paired_delimiters => 'more_delims', module_true => 'module_true', + class => 'class', ); # NOTE: If a feature is ever enabled in a non-contiguous range of Perl @@ -500,7 +501,7 @@ read_only_bottom_close_and_rename($h); __END__ package feature; -our $VERSION = '1.79'; +our $VERSION = '1.80'; FEATURES @@ -1298,6 +1299,17 @@ failures, but reaching the end of the module when this feature is in effect will prevent C<perl> from throwing an exception that the module "did not return a true value". +=head2 The 'class' feature + +B<WARNING>: This feature is still experimental and the implementation may +change or be removed in future versions of Perl. For this reason, Perl will +warn when you use the feature, unless you have explicitly disabled the warning: + + no warnings "experimental::class"; + +This feature enables the C<class> block syntax and other associated keywords +which implement the "new" object system, previously codenamed "Corinna". + =head1 FEATURE BUNDLES It's possible to load multiple features together, using diff --git a/regen/keywords.pl b/regen/keywords.pl index 7164fe2336..2438436bf0 100755 --- a/regen/keywords.pl +++ b/regen/keywords.pl @@ -51,6 +51,10 @@ my %feature_kw = ( catch => 'try', finally => 'try', defer => 'defer', + class => 'class', + field => 'class', + method => 'class', + ADJUST => 'class', ); my %pos = map { ($_ => 1) } @{$by_strength{'+'}}; @@ -119,6 +123,7 @@ __END__ +__DATA__ +__END__ -__SUB__ ++ADJUST +AUTOLOAD +BEGIN +UNITCHECK @@ -144,6 +149,7 @@ __END__ -chown -chr -chroot +-class -close -closedir -cmp @@ -179,6 +185,7 @@ __END__ -exp -fc -fcntl +-field -fileno +finally -flock @@ -244,6 +251,7 @@ __END__ -lt +m +map +-method -mkdir -msgctl -msgget diff --git a/regen/opcodes b/regen/opcodes index 98669955f2..9063072d6d 100644 --- a/regen/opcodes +++ b/regen/opcodes @@ -600,3 +600,5 @@ is_tainted is_tainted ck_null fs1 # exists-or; not currently exposed as a Perl-callable op helemexistsor hash element exists or ck_helemexistsor | S S + +methstart method start ck_null + diff --git a/regen/warnings.pl b/regen/warnings.pl index 55b98bc6f6..98e6b6cab9 100644 --- a/regen/warnings.pl +++ b/regen/warnings.pl @@ -16,7 +16,7 @@ # # This script is normally invoked from regen.pl. -$VERSION = '1.61'; +$VERSION = '1.62'; BEGIN { require './regen/regen_lib.pl'; @@ -146,6 +146,8 @@ my $TREE = { [ 5.035, DEFAULT_ON], 'experimental::extra_paired_delimiters' => [ 5.035, DEFAULT_ON], + 'experimental::class' => + [ 5.037, DEFAULT_ON ], }], 'missing' => [ 5.021, DEFAULT_OFF], |