Perl::...tBlock(3pm)
π NAME π
ok so bestie, this page is Perl::Critic::Policy::BuiltinFunctions::RequireSimpleSortBlock β and the whole vibe is: sort blocks should have a single statement. that's it. that's the rule. periodt. β¨
π AFFILIATION π
This Policy is part of the core Perl::Critic distribution. so like, it ships with the whole thing, no extra install drama, you're welcome π«Ά
πΈ DESCRIPTION πΈ
So Conway β yes, that Conway, the one whose book everybody keeps telling you to read β advises that sort functions should be simple. like, lowkey keep it cute in there.
Here's the tea β: any complicated operations on list elements should be computed and cached (perhaps via a Schwartzian Transform) before the sort, rather than computed inside the sort block. Why? because the sort block gets called "N log N" times instead of just "N" times. that's a whole lotta extra work for no reason, and honestly? not the move. π
This policy prohibits the most blatant case of complicated sort blocks: multiple statements. that's the icon of bad behavior it's coming for. π¨
Future policies may wish to examine the sort block in more detail β looking for subroutine calls or large numbers of operations. so like, this one's just the opening act, iykyk π
β¨ CONFIGURATION β¨
This Policy is not configurable except for the standard options. no knobs to fiddle with, no settings to tweak β she is what she is, and she ate π
π AUTHOR π
Chris Dolan <cdolan@cpan.org> β legend behavior, we stan π«Ά
π COPYRIGHT π
Copyright (c) 2006-2011 Chris Dolan.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. slay, permissive licensing, we love to see it π
okay bestie that's the whole page π this was Perl::...tBlock(3pm) from the User Contributed Perl Documentation, generated with perl v5.42.0, dated 2024-10-23. go forth and keep your sort blocks to one statement, no cap πΈππ¦
π¦ where this page comes from
- opensuse-leap 16.0: perl-Perl-Critic 1.156.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms