Perl::...iltins(3pm)
π NAME
Okay bestie, so this page is Perl::...iltins(3pm) β a User Contributed Perl Documentation page, no big deal β and the actual policy it's describing is Perl::Critic::Policy::CodeLayout::ProhibitParensWithBuiltins, which basically screams at you to write open $handle, $path instead of open($handle, $path). That's the whole vibe. β¨
π«Ά AFFILIATION
This Policy is part of the core Perl::Critic distribution. So like, it ships with the thing, you don't gotta go hunting. π
πΈ DESCRIPTION
So Conway (yes, that Conway) suggests that all built-in functions should be called without parentheses around the argument list. It's giving minimalism. It reduces visual clutter and it disambiguates built-in functions from user functions β which honestly? Iconic. π₯
There are exceptions though: my, local, and our are the special little guys that require parentheses when called with multiple arguments.
open($handle, '>', $filename); #not ok
open $handle, '>', $filename; #ok
split(/$pattern/, @list); #not ok
split /$pattern/, @list; #ok
See how much cleaner that is without the parens? The way the second one in each pair just breathes. π
β¨ CONFIGURATION
This Policy is not configurable except for the standard options. That's it, that's the whole tea. π
π NOTES
Lowkey important one here: coding with parentheses can sometimes lead to verbose and awkward constructs, so the author thinks the intent of Conway's guideline is to remove only the unnecessary parentheses. Makes sense, right? π§
So this policy makes exceptions for some common situations where parentheses are usually required. But β and this is the "listen bestie" part β you may find other situations where the parentheses are necessary to enforce precedence, but they still cause violations. Awkward. π In those cases, consider using the ## no critic comments to silence Perl::Critic. Saved your life fr fr. π«Ά
π BUGS
Some builtin functions (particularly those that take a variable number of scalar arguments) should probably get parentheses. Yeah. π
This policy should be enhanced to allow the user to specify a list of builtins that are exempt from the policy β but as of right now, it doesn't. No cap.
π AUTHOR
Jeffrey Ryan Thalhammer <jeff@imaginative-software.com> β the main character who made this. π
β COPYRIGHT
Copyright (c) 2005-2011 Imaginative Software Systems. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. The full text of this license can be found in the LICENSE file included with this module. π
π¦ Written by perl, versionv5.42.0, dated2024-10-23, and this page you just read isPerl::...iltins(3pm). Slay, go forth and delete those unnecessary parentheses π β¨
π¦ 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