role Metamodel::Stashing { }
Warning : this role is part of the Rakudo implementation, and is not a part of the language specification.
Types may have a stash associated with them, which is a named hash containing our-scoped symbols for that type's package. When this is the case, they can be used like namespaces; you can get their stash using their WHO
property or with the ::
dispatch operator:
module Nested {
module Namespace {
constant Symbol = $ ? MODULE ;
}
}
say Nested :: Namespace :: Symbol ;
say Nested . WHO < Namespace > . WHO < Symbol > ;
Metamodel::Stashing
is the metarole that handles creating and setting a stash object for types. Types used with this metarole are expected to support naming, so when writing custom HOWs that do it, ensure they also do Metamodel::Naming .
method add_stash ( $ type_obj )
Creates and sets a stash for a type, returning $type_obj
.
This method is typically called as the last step of creating a new type. For example, this is how it would be used in a minimal HOW that only supports naming and stashing:
class WithStashHOW
does Metamodel :: Naming
does Metamodel :: Stashing
{
method new_type ( WithStashHOW : _ : Str : D : $ name ! --> Mu ) {
my WithStashHOW : D $ meta := self . new ;
my Mu $ type := Metamodel :: Primitives . create_type : $ meta , ' Uninstantiable ' ;
$ meta . set_name : $ type , $ name ;
self . add_stash : $ type
}
}
my Mu constant WithStash = WithStashHOW . new_type : : name < WithStash > ;
say WithStash . WHO ;
Type relations for Metamodel::Stashing
perl6-type-graph
Metamodel::Stashing
Metamodel::Stashing
Mu
Mu
Any
Any
Any->Mu
Metamodel::Naming
Metamodel::Naming
Metamodel::AttributeContainer
Metamodel::AttributeContainer
Metamodel::MethodContainer
Metamodel::MethodContainer
Metamodel::MultiMethodContainer
Metamodel::MultiMethodContainer
Metamodel::RoleContainer
Metamodel::RoleContainer
Metamodel::BaseType
Metamodel::BaseType
Metamodel::MROBasedMethodDispatch
Metamodel::MROBasedMethodDispatch
Metamodel::MROBasedTypeChecking
Metamodel::MROBasedTypeChecking
Metamodel::BUILDPLAN
Metamodel::BUILDPLAN
Metamodel::BoolificationProtocol
Metamodel::BoolificationProtocol
Metamodel::Mixins
Metamodel::Mixins
Metamodel::EnumHOW
Metamodel::EnumHOW
Metamodel::EnumHOW->Metamodel::Stashing
Metamodel::EnumHOW->Any
Metamodel::EnumHOW->Metamodel::Naming
Metamodel::EnumHOW->Metamodel::AttributeContainer
Metamodel::EnumHOW->Metamodel::MethodContainer
Metamodel::EnumHOW->Metamodel::MultiMethodContainer
Metamodel::EnumHOW->Metamodel::RoleContainer
Metamodel::EnumHOW->Metamodel::BaseType
Metamodel::EnumHOW->Metamodel::MROBasedMethodDispatch
Metamodel::EnumHOW->Metamodel::MROBasedTypeChecking
Metamodel::EnumHOW->Metamodel::BUILDPLAN
Metamodel::EnumHOW->Metamodel::BoolificationProtocol
Metamodel::EnumHOW->Metamodel::Mixins
Metamodel::Documenting
Metamodel::Documenting
Metamodel::TypePretense
Metamodel::TypePretense
Metamodel::MethodDelegation
Metamodel::MethodDelegation
Metamodel::PackageHOW
Metamodel::PackageHOW
Metamodel::PackageHOW->Metamodel::Stashing
Metamodel::PackageHOW->Any
Metamodel::PackageHOW->Metamodel::Naming
Metamodel::PackageHOW->Metamodel::Documenting
Metamodel::PackageHOW->Metamodel::TypePretense
Metamodel::PackageHOW->Metamodel::MethodDelegation
Metamodel::Versioning
Metamodel::Versioning
Metamodel::MultipleInheritance
Metamodel::MultipleInheritance
Metamodel::C3MRO
Metamodel::C3MRO
Metamodel::NativeHOW
Metamodel::NativeHOW
Metamodel::NativeHOW->Metamodel::Stashing
Metamodel::NativeHOW->Any
Metamodel::NativeHOW->Metamodel::Naming
Metamodel::NativeHOW->Metamodel::MROBasedMethodDispatch
Metamodel::NativeHOW->Metamodel::MROBasedTypeChecking
Metamodel::NativeHOW->Metamodel::Documenting
Metamodel::NativeHOW->Metamodel::Versioning
Metamodel::NativeHOW->Metamodel::MultipleInheritance
Metamodel::NativeHOW->Metamodel::C3MRO
Metamodel::PrivateMethodContainer
Metamodel::PrivateMethodContainer
Metamodel::RolePunning
Metamodel::RolePunning
Metamodel::ParametricRoleHOW
Metamodel::ParametricRoleHOW
Metamodel::ParametricRoleHOW->Metamodel::Stashing
Metamodel::ParametricRoleHOW->Any
Metamodel::ParametricRoleHOW->Metamodel::Naming
Metamodel::ParametricRoleHOW->Metamodel::AttributeContainer
Metamodel::ParametricRoleHOW->Metamodel::MethodContainer
Metamodel::ParametricRoleHOW->Metamodel::MultiMethodContainer
Metamodel::ParametricRoleHOW->Metamodel::RoleContainer
Metamodel::ParametricRoleHOW->Metamodel::Documenting
Metamodel::ParametricRoleHOW->Metamodel::TypePretense
Metamodel::ParametricRoleHOW->Metamodel::Versioning
Metamodel::ParametricRoleHOW->Metamodel::MultipleInheritance
Metamodel::ParametricRoleHOW->Metamodel::PrivateMethodContainer
Metamodel::ParametricRoleHOW->Metamodel::RolePunning
Metamodel::Finalization
Metamodel::Finalization
Metamodel::DefaultParent
Metamodel::DefaultParent
Metamodel::Trusting
Metamodel::Trusting
Metamodel::ClassHOW
Metamodel::ClassHOW
Metamodel::ClassHOW->Metamodel::Stashing
Metamodel::ClassHOW->Any
Metamodel::ClassHOW->Metamodel::Naming
Metamodel::ClassHOW->Metamodel::AttributeContainer
Metamodel::ClassHOW->Metamodel::MethodContainer
Metamodel::ClassHOW->Metamodel::MultiMethodContainer
Metamodel::ClassHOW->Metamodel::RoleContainer
Metamodel::ClassHOW->Metamodel::MROBasedMethodDispatch
Metamodel::ClassHOW->Metamodel::MROBasedTypeChecking
Metamodel::ClassHOW->Metamodel::BUILDPLAN
Metamodel::ClassHOW->Metamodel::BoolificationProtocol
Metamodel::ClassHOW->Metamodel::Mixins
Metamodel::ClassHOW->Metamodel::Documenting
Metamodel::ClassHOW->Metamodel::Versioning
Metamodel::ClassHOW->Metamodel::MultipleInheritance
Metamodel::ClassHOW->Metamodel::C3MRO
Metamodel::ClassHOW->Metamodel::PrivateMethodContainer
Metamodel::ClassHOW->Metamodel::Finalization
Metamodel::ClassHOW->Metamodel::DefaultParent
Metamodel::ClassHOW->Metamodel::Trusting
Metamodel::ParametricRoleGroupHOW
Metamodel::ParametricRoleGroupHOW
Metamodel::ParametricRoleGroupHOW->Metamodel::Stashing
Metamodel::ParametricRoleGroupHOW->Any
Metamodel::ParametricRoleGroupHOW->Metamodel::Naming
Metamodel::ParametricRoleGroupHOW->Metamodel::BoolificationProtocol
Metamodel::ParametricRoleGroupHOW->Metamodel::TypePretense
Metamodel::ParametricRoleGroupHOW->Metamodel::RolePunning
Metamodel::ModuleHOW
Metamodel::ModuleHOW
Metamodel::ModuleHOW->Metamodel::Stashing
Metamodel::ModuleHOW->Any
Metamodel::ModuleHOW->Metamodel::Naming
Metamodel::ModuleHOW->Metamodel::Documenting
Metamodel::ModuleHOW->Metamodel::TypePretense
Metamodel::ModuleHOW->Metamodel::MethodDelegation
Metamodel::ModuleHOW->Metamodel::Versioning
Expand above chart