role Metamodel::ParametricRoleGroupHOW

Represents a group of roles with different parameterizations

class Metamodel::ParametricRoleGroupHOW
    does Metamodel::Naming
    does Metamodel::Documenting
    does Metamodel::Stashing
    does Metamodel::TypePretense
    does Metamodel::RolePunning
    does Metamodel::BoolificationProtocol {}

Warning: this role is part of the Rakudo implementation, and is not a part of the language specification.

A ParametricRoleGroupHOW groups a set of ParametricRoleHOW, every one of them representing a single role declaration with their own parameter sets.

(role Zape[::T{}).HOW.say# OUTPUT: «Perl6::Metamodel::ParametricRoleHOW.new␤» 
Zape.HOW.say ; # OUTPUT: «Perl6::Metamodel::ParametricRoleGroupHOW.new␤» 

ParametricRoleHOWs need to be added to this kind of group:

my \zape := Metamodel::ParametricRoleGroupHOW.new_typename => "zape");
my \zipi := Metamodel::ParametricRoleHOW.new_typename => "zipi"group => zape);
say zipi.HOW# OUTPUT: «Perl6::Metamodel::ParametricRoleHOW.new␤» 

Note: As most of the Metamodel classes, this class is here mainly for illustration purposes and it's not intended for the final user to instantiate.

Type Graph

Type relations for 404

Expand above chart

Routines supplied by role Metamodel::Naming

Metamodel::ParametricRoleGroupHOW does role Metamodel::Naming, which provides the following routines:

(Metamodel::Naming) method name

method name($type)

Returns the name of the metaobject, if any.

say 42.^name;       # OUTPUT: «Int␤»

(Metamodel::Naming) method set_name

method set_name($type$new_name)

Sets the new name of the metaobject.

Routines supplied by role Metamodel::Stashing

Metamodel::ParametricRoleGroupHOW does role Metamodel::Stashing, which provides the following routines:

(Metamodel::Stashing) 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:

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␤»