summaryrefslogtreecommitdiff
path: root/pod/perldelta.pod
diff options
context:
space:
mode:
authorYves Orton <demerphq@gmail.com>2023-01-08 15:49:04 +0100
committerYves Orton <demerphq@gmail.com>2023-01-19 18:44:49 +0800
commitc224bbd5d135fe48f49b4cc25f10a4977d695145 (patch)
tree5909b6fd666bb025496824a3f8c67715643164a8 /pod/perldelta.pod
parent09b3a407e87f128d7aecd14f9c8d75dcff9aaaf8 (diff)
downloadperl-c224bbd5d135fe48f49b4cc25f10a4977d695145.tar.gz
regcomp.c - add optimistic eval (*{ ... }) and (**{ ... })
This adds (*{ ... }) and (**{ ... }) as equivalents to (?{ ... }) and (??{ ... }). The only difference being that the star variants are "optimisitic" and are defined to never disable optimisations. This is especially relevant now that use of (?{ ... }) prevents important optimisations anywhere in the pattern, instead of the older and inconsistent rules where it only affected the parts that contained the EVAL. It is also very useful for injecting debugging style expressions to the pattern to understand what the regex engine is actually doing. The older style (?{ ... }) variants would change the regex engines behavior, meaning this was not as effective a tool as it could have been. Similarly it is now possible to test that a given regex optimisation works correctly using (*{ ... }), which was not possible with (?{ ... }).
Diffstat (limited to 'pod/perldelta.pod')
-rw-r--r--pod/perldelta.pod14
1 files changed, 14 insertions, 0 deletions
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index a4cbfbe4a2..81b99f8630 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -27,6 +27,20 @@ here, but most should go in the L</Performance Enhancements> section.
[ List each enhancement as a =head2 entry ]
+=head2 Optimistic Eval in Patterns
+
+The use of C<(?{ ... })> and C<(??{ ... })> in a pattern disables various
+optimizations globally in that pattern. This may or may not be desired by the
+programmer. This release adds the C<(*{ ... })> and C<(**{ ... })>
+equivalents. The only difference is that they do not and will never disable
+any optimisations in the regex engine. This may make them more unstable in the
+sense that they may be called more or less times in the future, however the
+number of times they execute will truly match how the regex engine functions.
+For example, certain types of optmisation are disabled when C<(?{ ... })> is
+included in a pattern, so that patterns which are O(N) in normal use become
+O(N*N) with a C<(?{ ... })> pattern in them. Switching to C<(*{ ... })> means
+the pattern will stay O(N).
+
=head1 Security
XXX Any security-related notices go here. In particular, any security