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 (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