Full
view release on metacpan or search on metacpan
lib/Full/Pragmata.pm view on Meta::CPAN
use Full::Pragmata qw(:v1);
Currently C<:v1> is the only version available. It's very likely that future versions
will bring in new functionality or enable/disable a different featureset, or may
remove functionality or behaviour that's no longer appropriate.
=cut
no indirect qw(fatal);
no multidimensional;
no bareword::filehandles;
use mro;
use experimental qw(signatures);
use meta;
no warnings qw(meta::experimental);
use curry;
use Data::Checks;
use Object::Pad::FieldAttr::Checked;
use Sublike::Extended;
use Signature::Attribute::Checked;
use Future::AsyncAwait;
use Future::AsyncAwait::Hooks;
use Syntax::Keyword::Try;
use Syntax::Keyword::Dynamically;
use Syntax::Keyword::Defer;
use Syntax::Keyword::Match;
use Syntax::Operator::Equ;
use Scalar::Util;
use List::Util;
use List::Keywords;
use Future::Utils;
use Module::Load ();
use JSON::MaybeUTF8;
use Unicode::UTF8;
use Log::Any qw($log);
use Metrics::Any;
use constant USE_OPENTELEMETRY => $ENV{USE_OPENTELEMETRY};
BEGIN {
if(USE_OPENTELEMETRY) {
require OpenTelemetry;
require OpenTelemetry::Context;
require OpenTelemetry::Trace;
require OpenTelemetry::Constants;
}
}
sub import ($called_on, $version_tag, %args) {
die "invalid version, expecting something like use @{[caller]} qw(:v1);"
unless my $version = $version_tag =~ /^:v([0-9]+)/;
my $pkg = $args{target} // caller(0);
my $class = __PACKAGE__;
# Apply core syntax and rules
strict->import;
warnings->import;
utf8->import;
# We want mostly the 5.36 featureset, but since that includes `say` and `switch`
# we need to customise the list somewhat
feature->import(qw(
bitwise
current_sub
evalbytes
fc
postderef_qq
state
unicode_eval
unicode_strings
));
# Indirect syntax is problematic due to `unknown_sub { ... }` compiling and running
# the block without complaint, and only failing at runtime *after* the code has
# executed once - particularly unfortunate with try/catch
indirect->unimport(qw(fatal));
# Multidimensional array access - $x{3,4} - is usually a sign that someone wanted
# `@x{3,4}` or similar instead, so we disable this entirely
multidimensional->unimport;
# Plain STDIN/STDOUT/STDERR are still allowed, although hopefully never used by
# service code - new filehandles need to be lexical.
bareword::filehandles->unimport;
# This one's needed for nested scope, e.g. { package XX; use Full::Service; method xxx (%args) ... }
experimental->import('signatures');
# We don't really care about diamond inheritance, since microservices are expected
# to have minimal inheritance in the first place, but might as well have a standard
# decision to avoid surprises in future
mro::set_mro($pkg => 'c3');
# Helper functions which are used often enough to be valuable as a default
Scalar::Util->export($pkg => qw(refaddr blessed weaken));
List::Util->export($pkg => qw(min max sum0));
# Additional features in :v2 onwards
List::Util->export($pkg => qw(uniqstr));
# eval "package $pkg; use Object::Pad::FieldAttr::Checked; use Data::Checks qw(NumGE); 1" or die $@;
Object::Pad::FieldAttr::Checked->import($pkg);
Sublike::Extended->import;
Signature::Attribute::Checked->import($pkg);
Data::Checks->import(qw(
Defined
Object
Str
Num
StrEq
NumGT
NumGE
NumLE
NumLT
NumRange
NumEq
Isa
ArrayRef
HashRef
( run in 3.145 seconds using v1.01-cache-2.11-cpan-437f7b0c052 )