add_stash
ErrorsCollection

add_stash

Synthesised documentation from type/Metamodel/Stashing

From type/Metamodel/Stashing

See Original text in context

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# OUTPUT: «WithStash␤»