-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarifications on PPC0027 #60
base: main
Are you sure you want to change the base?
Conversation
Should it be called list_utils if it only includes any and all? I would say they are the most commonly used that require special syntax, but what if we want to add first or reduce in the future? Or would we consider whether to add them as part of this PPC? |
Why not simply Possibly
How different is Do we have a better name under which put all these list-processing operations? I would hate to end up with If we do multiple batches, we can have |
I was hoping we'd add all the functions in the same release, even if not the same actual commit. It won't matter too much if we add a few at 5.41.7, .8, .9... as long as the set of them is fixed by the time we make the next release (of whatever version number it has). I think that would be better than lots of single-function named features. |
Well consider this my vote for adding 'first' at least. reduce I think needs a better way than $a and $b but if that can be resolved that would be nice to have too. none and notall are simple inversions of any and all so I'm not sure they're worth the feature bundle keywords. Original PR for discussion: #50 |
There's a couple of fun options under "Deprecated and removed variables" in perlvar, I like my $sum = reduce { $* += $_ } @numbers;
my $grouped = reduce { $#->{ $_ } ++ } @numbers |
I don't think that giving a new meaning to a deprecated variable is the right approach. If anything, we should have a keyword for the accumulator ( |
We know they're already valid syntax and they've been available since 5.10 (perlvar) Flavour-wise, I'd like it to be a single character variable so I don't have to repeat myself like I do in: my $sum; $sum += $_ for @numbers;
Can't one trust autoviv deal with the collector becoming a hash-ref? |
What about |
If we want a I wanted to clarify here first what the feature/warning name would be, and also the alias/copy/readonly-copy behaviour of |
Differing in behavior from grep/map would be extremely surprising. If map/grep use aliases, any/all should as well. |
My second-hand memory of this is that one is using aliases and not the other. |
|
OK, that's what my memory was about: the returned values. If these are meant to be analogues of |
My thinking here was that the aliasing behaviour is basically never used intentionally and any time it comes up it's always been a bug that has caused accidental modification. The fact that these new operators already don't support the Alternatively, this could be something we fix later if/when we get around to adding named lexicals to the blocks. Perhaps a if(any my $x :ro { $x is now readonly copy of list } @things) { ... } but at that point, much like the long history of things like |
Why not? Many people love to use the Also, should these eventually support the proposed topicalization behaviour for Meaning:
|
This was already mentioned in the original PPC0027. Avoiding that syntax avoids a bunch of parser ambiguities that makes the-below easier to handle.
Yes - the intention is that these can easily support that final idea. By not supporting the deferred expression form, those become easier to handle. |
@book If you want to rename @leonerd we already have a tool for that, copy the list yourself: if(any my $x { $x is now readonly copy of the item } (my @scratch=@things) ) { ... } To echo @haarg, I agree that It's more important that the list aliasing semantics be consistent than "nice". I'd vote for individual responsibility, in the form of a lexical pragma to make the list copying opt-in, so one can keep the faster (not copying) up until they need the slower, safer version (IE when they discover the people they work with keep submitting "oops I overwrote the thing on accident" patches). Perhaps: use more 'list copies'; # -or-
use Readonly qw[ grep map ]; ... like that, but not that |
|
ce3a7c9
to
5888878
Compare
As the idea for read-only copies of data in What is the decision on feature flag name for these operators? Are we sticking with |
We discussed this during the PSC meeting today. Assuming we're not constrained in the ever-growing number of feature flags, there should simply be one flag per symbol (so We also looked at the policy, and we want to make it possible to progress quickly on this, so that the features can be marked as experimental (because of the change in behavior from the |
OK; I can do that. Though perhaps we should add some specific wording in the docs pointing out the case for use feature 'all';
no warnings 'experimental::all'; |
This makes me realize that |
My personal thought is that I think it's fine. People really shouldn't be doing I've added a small extra detail to the docs in
|
To me it feels like being defensive in some POD doesn't really address the usability issue of calling a single feature "all" |
PR Perl/perl5#22773 is currently paused awaiting a resolution on this question. At present it's implemented with two separate feature flags, named |
I don't particularly like the conflation with 'all' but at the same time, I've never seen the ':all' flag used and frankly it should be deprecated (in both the use and no case, given our negative features). |
@Grinnz Indeed - I think especially in the case of |
As discussed in Perl/PPCs#60, `:all` is very unlikely to be useful. Since it will enable all features a future Perl might support, it will also enable some that might be incompatible with the code as written (see `bitwise`, for example, which changes the meaning of the existing bitwise operators). With the addition of "negative" features in v5.32, `:all` became even less useful, since it would re-enable features deemed undesirable in modern Perl. As this point in time, `:all` is effectively a footgun. If the keyword `all` (from PPC0027) is added as a feature, there's an extra risk of confusion between `use feature 'all'` and `use feature ':all'`. This patch makes `:all` warn. We should consider removing that bundle entirely in the future.
As discussed in Perl/PPCs#60, `:all` is very unlikely to be useful. Since it will enable all features a future Perl might support, it will also enable some that might be incompatible with the code as written (see `bitwise`, for example, which changes the meaning of the existing bitwise operators). With the addition of "negative" features in v5.32, `:all` became even less useful, since it would re-enable features deemed undesirable in modern Perl. As this point in time, `:all` is effectively a footgun. If the keyword `all` (from PPC0027) is added as a feature, there's an extra risk of confusion between `use feature 'all'` and `use feature ':all'`. This patch makes `:all` warn. We should consider removing that bundle entirely in the future.
I use it all the time. And I would absolutely expect it from list ops that are essentially specializations of |
5888878
to
5baf2c9
Compare
Closes the existing "open issues" with regard to naming of the feature flag.
Also opens one new issue to do with aliasing vs. copy of
$_
.