Skip to content
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

Discuss if and where we should use the state variables #7031

Open
yuktea opened this issue Jul 7, 2022 · 3 comments
Open

Discuss if and where we should use the state variables #7031

yuktea opened this issue Jul 7, 2022 · 3 comments
Labels
refactor Request for Comments ⏰ Stale This issue hasn't seen activity in a while. You can try documenting more to unblock it.

Comments

@yuktea
Copy link
Contributor

yuktea commented Jul 7, 2022

What

  • Using state for when we have larger things to work with some bigger/costlier things (maybe large regex), which we could scope to a function without spending reinitialization costs. We could discuss where and if we should use it in this thread here.
  • A little Context: https://perlmaven.com/static-and-state-variables-in-perl

Part of

@alexgarel
Copy link
Member

alexgarel commented Jul 8, 2022

For regexp initialization, it seems that using qr operator with constants or Fast::Const can be a way to go.

$ my constant $p = qr/t.st+ *moi/i
$Regexp1 = (?^i:t.st+ *moi);

$ $p
$Regexp1 = (?^i:t.st+ *moi);

$ "test moi" =~ $p
1

@stephanegigandet
Copy link
Contributor

FYI, state arrays and hashes can't be initialized in Perl versions earlier than 5.28 (we use 5.24 in prod)

#7058

@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the ⏰ Stale This issue hasn't seen activity in a while. You can try documenting more to unblock it. label Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Request for Comments ⏰ Stale This issue hasn't seen activity in a while. You can try documenting more to unblock it.
Projects
Status: To discuss and validate
Development

No branches or pull requests

4 participants