Skip to content

Commit

Permalink
Suggest that the feature flag should be called 'list_utils'; reminisc…
Browse files Browse the repository at this point in the history
…ent of the List::Util module name
  • Loading branch information
leonerd committed Nov 25, 2024
1 parent b855389 commit 5f959cd
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions ppcs/ppc0027-any-and-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ Most code of any appreciable size tends to make use of at least the `any` or `al

## Specification

New named features that, when enabled, activate syntax analogous to the existing `grep` operator, named `any` and `all`:
A new named feature that, when enabled, activates new operators analogous to the existing `grep` operator, named `any` and `all`:

```perl
use feature 'list_utils';

any { BLOCK } LIST

all { BLOCK } LIST
Expand Down Expand Up @@ -50,17 +52,17 @@ Some::Class->new(

## Backwards Compatibility

As these new operators are guarded by named features, there are no immediate concerns with backward compatiblity in the short-term.
As these new operators are guarded by a named feature, there are no immediate concerns with backward compatiblity in the short-term.

In the longer term, if these named features become part of a versioned feature bundle that is enabled by a corresponding `use VERSION` declaration there may be concerns that the names collide with functions provided by `List::Util` or similar modules. As the intention of these operators is to provide the same behaviour, this is not considered a major problem. Differences due to caller scope as outlined above may be surprising to a small number of users.
In the longer term, if this named feature becomes part of a versioned feature bundle that is enabled by a corresponding `use VERSION` declaration there may be concerns that the names collide with functions provided by `List::Util` or similar modules. As the intention of these operators is to provide the same behaviour, this is not considered a major problem. Differences due to caller scope as outlined above may be surprising to a small number of users.

## Security Implications

## Examples

```perl
use v5.40;
use feature 'any';
use feature 'list_utils';

if( any { $_ > 10 } 5, 10, 15, 20 ) { say "A number above 10" }
```
Expand Down Expand Up @@ -114,10 +116,6 @@ In any case, as junctions behave like values, they do not require special syntax

## Open Issues

* There could be anything up to five new operators added by this idea. Do they all get their own named feature flags? Do they all live under one flag?

* Should the flag be called `any`? That might be confusing as compared to the `:any` import tag which would request all features.

## Copyright

Copyright (C) 2024, Paul Evans.
Expand Down

0 comments on commit 5f959cd

Please sign in to comment.