Metamodel::Stashing Reference
Metarole for type stashes
What it is #
Position in the hierarchy #
| Inherits from | — |
| Does | — |
| Consumed by | Metamodel::ClassHOW, Metamodel::EnumHOW, Metamodel::ModuleHOW, Metamodel::NativeHOW, Metamodel::PackageHOW, Metamodel::ParametricRoleGroupHOW, Metamodel::ParametricRoleHOW |
Routines #
Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.
method add_stash #
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:
Examples, run three ways #
Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.
1 no-output · 2 rakupp-differs
role Metamodel::Stashing { }Not executed: the documentation states no expected output for this example.
module Nested {
module Namespace {
constant Symbol = $?MODULE;
}
}
say Nested::Namespace::Symbol; # OUTPUT: «(Namespace)»
say Nested.WHO<Namespace>.WHO<Symbol>; # OUTPUT: «(Namespace)»(Namespace)
(Namespace)
(Namespace)
(Namespace)
(Any)
0
Raku++ disagrees with both the documentation and Rakudo — a defect.
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; # OUTPUT: «WithStash»WithStash
WithStash
Raku++ disagrees with both the documentation and Rakudo — a defect.