attributes#
The machinery behind sub foo : lvalue method { ... } and my $x : Shared.
Perl attaches attributes to subs and variables in three ways, and this module is the meeting point for all of them:
Built-in attributes that Perl itself consumes —
lvalue,method,const,prototype(...)on subs,sharedon variables. These flip flags on theCV(or set a prototype string) and never leave the core.User-defined attributes — any name Perl doesn’t recognise is handed off to
MODIFY_${type}_ATTRIBUTESin the caller’s package. If that handler rejects an attribute (or is absent), the declaration is a fatal error.FETCH_${type}_ATTRIBUTESis the read-side counterpart.A query API —
attributes::get($ref)returns the combined built-in + user-defined attribute list for a referent;reftypeis kept here as a backward-compatible alias forbuiltin::reftype.
Attribute syntax is parsed by perl and the resulting list arrives here
via use attributes PACKAGE, \&sub, @attrs — see the upstream
attributes POD for the full compile-time expansion.
Functions#
Query#
get#
List every attribute set on a referent — both the built-ins Perl recognises and any package-defined ones returned by a FETCH_${type}_ATTRIBUTES handler.
reftype#
Return the underlying storage type of a reference, ignoring any class it’s been blessed into.
Low-level#
modify_attrs#
Apply a list of attributes to a referent and return the ones Perl didn’t recognise, so the caller can hand them to a user-defined MODIFY_${type}_ATTRIBUTES handler.
fetch_attrs#
Return the built-in attributes currently set on a referent.
guess_stash#
Work out which package a reference “belongs to”, for the purpose of looking up FETCH_${type}_ATTRIBUTES / MODIFY_${type}_ATTRIBUTES.