class Metamodel::PackageHOW
Metaobject representing a Raku package.
class Metamodel::PackageHOW does Metamodel::Naming does Metamodel::Documenting does Metamodel::Stashing does Metamodel::TypePretense does Metamodel::MethodDelegation { }
Warning: this class is part of the Rakudo implementation, and is not a part of the language specification.
Metamodel::PackageHOW
is the metaclass behind the package
keyword.
package P {}; say P.HOW; # OUTPUT: «Perl6::Metamodel::PackageHOW.new»
Methods
method archetypes
Defined as:
method archetypes()
Returns the archetypes for this model, that is, the properties a metatype can implement.
method new
Defined as:
method new(*%named)
Creates a new PackageHOW
.
method new_type
Defined as:
method new_type(:$name = '<anon>', :$repr, :$ver, :$auth)
Creates a new package, with optional representation, version and auth field.
compose
Defined as:
method compose($obj, :$compiler_services)
Sets the metapackage as composed.
is_composed
Defined as:
method is_composed($obj)
Returns the composed status of the metapackage.
Type Graph
Metamodel::PackageHOW
Routines supplied by role Metamodel::Naming
Metamodel::PackageHOW 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::Documenting
Metamodel::PackageHOW does role Metamodel::Documenting, which provides the following routines:
(Metamodel::Documenting) method set_why
method set_why($why)
Sets the documentation for a type to $why
.
(Metamodel::Documenting) method WHY
method WHY()
Returns the documentation for a type.
Routines supplied by role Metamodel::Stashing
Metamodel::PackageHOW 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»