March 21, 2025·4 min read·engineeringperllanguage-designexperimental

Perl gives experimental list predicates explicit feature names

Perl 5.41.10 renames the guards for any and all without changing their behavior. The distinction between one keyword and the feature pragma's all bundle explains the change.

Enabling a keyword named all and enabling every language feature are different requests. Perl's experimental list predicates made those requests look too similar. Today's Perl 5.41.10 renames their feature guards to keyword_any and keyword_all, resolving a naming problem while the operators are still experimental. The release notes say their syntax and semantics have not changed.

The Perl history records date this development release to March 21. Its predicate operators first appeared in 5.41.7 under feature names matching their keywords. The problem was the existing :all feature bundle, whose name already meant enabling all features known to the pragma. One spelling referred to a list operation, while a closely related spelling referred to language configuration.

I value Perl's ability to express text operations directly, but the surrounding syntax needs to remain readable. An explicit feature name is a useful cost when it tells a reader which part of the grammar a file has enabled. The additional characters occur in the declaration, while the predicate expression stays concise.

The declaration changes with the warning category

The rename applies to both the feature flags and their experimental warning categories. Code adopting the development release needs experimental::keyword_any or experimental::keyword_all when deliberately suppressing the relevant warning. Updating only the feature declaration leaves the warning configuration describing an earlier name.

The feature pragma shipped in 5.41.10 documents the new names and keeps the experimental status explicit. Enabling one of these features permits its operator keyword. Suppressing its warning is a separate declaration. Neither action establishes that the experiment has become stable.

The release notes demonstrate the new keyword_all declaration with a block predicate. A complete example can use fixed input so the condition is unambiguous.

use v5.40;
use feature 'keyword_all';
no warnings 'experimental::keyword_all';

my @numbers = (2, 4, 8);
if (all { $_ % 2 == 0 } @numbers) {
    say "All the numbers are even";
}

This example requires the experimental implementation available in the development interpreter. The use v5.40 declaration does not add the new operator to a 5.40 interpreter. It supplies the baseline language declaration used by the release-note example, while the explicit feature request enables this particular experiment on an interpreter that implements it.

That distinction matters when reading version declarations in example code. A minimum language declaration and the availability of every explicitly requested feature are separate constraints. The example's visible guard records the experimental dependency instead of implying that the baseline version already included it.

A predicate can finish before the list ends

The versioned function documentation explains the operators in terms of a block evaluated for list elements. any returns true once a block evaluation succeeds. all returns false once an evaluation fails. Both locally set $_ to the current element while evaluating the block.

Their short-circuit behavior is the practical distinction from using grep to count matching elements. A condition based on grep can express a related question, but it does not give the same evaluation behavior. When a predicate's answer is already determined, these operators stop considering additional elements.

For all, a failed element settles the universal condition. In the example, an odd number would make the block false and determine the result at that position. For any, the first even number would settle the corresponding existential question. This gives a reader information about evaluation as well as about the intended Boolean result.

The distinction becomes observable if evaluating the block has effects. Counting matches and testing whether a match exists do not require the same number of block invocations. A block that changes state can therefore make superficially similar conditions behave differently. The documented early exit is part of the operator contract, not merely an implementation optimization.

This is the part of the experiment I find useful. The operator names state the question being asked, and their documented evaluation rule avoids pretending that a count is required. Perl already encourages compact expressions, so an operation with a narrow meaning can improve clarity when its use stays explicit.

Feature bundles need their own names

The pragma documentation says bundle names begin with a colon to distinguish them from individual features. That already gives the parser a distinction between all and :all. The rename addresses the human ambiguity left by giving unrelated requests the same word with different punctuation.

The implementation's feature map now contains keyword_any and keyword_all as individual entries. Its all bundle includes those entries among the other available features. The relationship is therefore visible in the data defining the pragma. The bundle collects features, while each renamed entry controls one keyword.

Changing the guard during experimentation also limits the scope of the compatibility change. The release notes explicitly preserve the operators' behavior since 5.41.7. Someone testing the previous development spelling has a declaration to update, without needing to reinterpret every predicate block. That is a smaller change than altering evaluation rules at the same time.

March's release leaves the experiment available under names that identify what they enable. The important compatibility detail is the pair of declarations at the top of an adopting file. Both the feature request and any targeted warning suppression now use the keyword_ names, while the actual any and all expressions retain their documented short-circuit behavior.