Perl::C...mmutable(3)

πŸ“¦
version 1.05 Β· 2 versions
, in fedora 43

πŸ’– NAME πŸ’–

Perl::Critic::Policy::Moose::RequireMakeImmutable β€” bestie, this is the policy that makes sure your Moose code is fast.

Oh also? This whole thing lives in the User Contributed Perl Documentation section of the manual, so you know it's the good stuff. πŸŽ€


✨ VERSION ✨

This is version 1.05. Slay.


🌸 DESCRIPTION 🌸

Okay so, Moose? Moose is so flexible. Like, ridiculously flexible. Main character energy, honestly. But β€” and I need you to hear me on this β€” that flexibility comes at a performance cost. 😭

The good news: you can ameliorate some of that cost by telling Moose when you're done putting your classes together. Like, "okay Moose, I'm finished, you can lock in now." πŸ’…

So the vibe check here is: if you use Moose, this policy requires that you call:

__PACKAGE__->meta()->make_immutable()

No call, no peace. 🫢


πŸ¦‹ AFFILIATION πŸ¦‹

This policy is part of Perl::Critic::Moose. That's its home. Its little nest. πŸͺΊ


πŸ’œ CONFIGURATION πŸ’œ

There is exactly one option: equivalent_modules. It lets you specify modules that should be treated the exact same way as Moose and Moose::Role β€” for example if you were doing something with Moose::Exporter. Iykyk. 😌

So say you had this in your .perlcriticrc file:

[Moose::RequireMakeImmutable]
equivalent_modules = MyCompany::Moose MooseX::NewThing

Then this following code would result in a violation:

package Baz;

use MyCompany::Moose;

sub new {
    ...
}

# no make_immutable call

Not me catching you slipping on the make_immutable call. πŸ™ˆ


⭐ SUPPORT ⭐

Bugs may be submitted through the RT bug tracker <http://rt.cpan.org/Public/Dist/Display.html?Name=Perl-Critic-Moose> (or to bug-perl-critic-moose@rt.cpan.org <mailto:bug-perl-critic-moose@rt.cpan.org>). πŸ’Œ

Also, I am usually active on IRC as 'drolsky' on irc://irc.perl.org. Come say hi, fr fr. πŸ‘‘


πŸŽ€ AUTHORS πŸŽ€

  • Elliot Shank <perl@galumph.com>
  • Dave Rolsky <autarch@urth.org>

Icons. Legends. The blueprint. πŸ”₯


This software is copyright (c) 2008 - 2016 by Elliot Shank.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. So go off, bestie. πŸ’–


perl v5.42.0 Β· 2025-07-25 β€” that's the whole manual, babes, and it's giving immaculate. Now go call make_immutable() and make your Moose code fast. Mwah. πŸ’…πŸŒΈβœ¨

πŸ“¦ where this page comes from