Combined from primary sources listed below.
See primary docmentation in context for method add.
method add_attribute($obj, $attribute)
Adds an attribute. $attribute must be an object that supports the methods name, type and package, which are called without arguments. It can for example be of type Attribute.
See primary docmentation in context for method add.
method add_private_method($obj, $name, $code)
Adds a private method $code with name $name.
See primary docmentation in context for method add.
method add_fallback($obj, $condition, $calculator)
Installs a method fallback, that is, add a way to call methods that weren't statically added.
Both $condition and $calculator must be callables that receive the invocant and the method name once a method is called that can't be found in the method cache.
If $condition returns a true value, $calculator is called with the same arguments, and must return the code object to be invoked as the method, and is added to the method cache.
If $condition returns a false value, the next fallback (if any) is tried, and if none matches, an exception of type X::Method::NotFound is thrown.
User-facing code (that is, code not dabbling with metaclasses) should use method FALLBACK instead.
See primary docmentation in context for method add.
method add_role($obj, Mu $role)
Adds the $role to the list of roles to be composed.
See primary docmentation in context for method add.
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»
See primary docmentation in context for method add.
$target.add-leading("additional");
Add a line to the leading documentation. Creates a RakuAST::Doc::Declarator object and sets it in the .WHY if there wasn't one already.
See primary docmentation in context for method add.
$target.add-trailing("additional");
Add a line to the trailing documentation. Creates a RakuAST::Doc::Declarator object and sets it in the .WHY if there wasn't one already.
See primary docmentation in context for method add.
method add_trustee($type, Mu $trustee)
Trust $trustee.
class A {
BEGIN A.^add_trustee(B);
# same as 'trusts B';
}
See primary docmentation in context for method add.
method add_parent($obj, $parent, :$hides)
Adds $parent as a parent type. If $hides is set to a true value, the parent type is added as a hidden parent.
$parent must be a fully composed typed. Otherwise an exception of type X::Inheritance::NotComposed is thrown.
See primary docmentation in context for method add.
method add(IO::Path:D: Str() $what --> IO::Path:D)
Concatenates a path fragment to the invocant and returns the resultant IO::Path. If adding ../ to paths that end with a file, you may need to call resolve for the resultant path to be accessible by other IO::Path methods like dir or open. See also sibling and parent.
"foo/bar".IO.mkdir;
"foo/bar".IO.add("meow") .resolve.relative.say; # OUTPUT: «foo/bar/meow»
"foo/bar".IO.add("/meow") .resolve.relative.say; # OUTPUT: «foo/bar/meow»
"foo/bar".IO.add("meow.txt").resolve.relative.say; # OUTPUT: «foo/bar/meow.txt»
"foo/bar".IO.add("../meow") .resolve.relative.say; # OUTPUT: «foo/meow»
"foo/bar".IO.add("../../") .resolve.relative.say; # OUTPUT: «.»
method add(IO::Path:D: *@parts --> IO::Path:D)
As of release 2021.07 of the Rakudo compiler, it is also possible to specify multiple parts to be added to a path.
"foo".IO.add(<bar baz>).resolve.relative.say; # OUTPUT: «foo/bar/baz»
See primary docmentation in context for method add.
$block.add-config(
'allow',
RakuAST::QuotedString.new(
processors => <words val>,
segments => (
RakuAST::StrLiteral.new("B C"),
)
)
);
Takes a key and a value to add to the configuration. Value is expected to be either a string or a RakuAST object.
See primary docmentation in context for method add.
$block.add-paragraph("baz\n\n");
Add a paragraph: should be a string, or a RakuAST::Doc::Paragraph object.
See primary docmentation in context for method add.
$declarator.add-trailing("additional");
Add a line to the trailing documentation.
See primary docmentation in context for method add.
See primary docmentation in context for method add.
method add_method($obj, $name, $code)
Adds a method to the metaclass, to be called with name $name. This should only be done before a type is composed.
See primary docmentation in context for method add.
method add_enum_value($obj, $value)
Adds a value to this enum. $value should be an instance of the enum itself, as type Enumeration.
See primary docmentation in context for method add.
method add_parent($obj, $parent)
Sets the base type of an enum. This can only be used if no base type was passed to .new_type.
See primary docmentation in context for method add.
$markup.add-atom( ("foo",) );
Add an atom to the atoms of the object. Values are expected to be either a string, or a RakuAST::Doc::Markup object.
See primary docmentation in context for method add.
$markup.add-meta( ("bar",) );
Add an item to the meta-information of the object. Values are expected to be either a string, or a RakuAST::Doc::Markup object.
See primary docmentation in context for method add.
$paragraph.add-atom("baz\n");
Add an atom: should be a string, or a RakuAST::Doc::Markup object.
See primary docmentation in context for method add.
method add(BagHash: \to-add, *%_ --> Nil)
When to-add is a single item, add inserts it into the BagHash or, if it was already present, increases its weight by 1. When to-add is a List, Array, Seq, or any other type that does the Iterator Role, add inserts each element of the Iterator into the SetHash or increments the weight of each element by 1.
Note: Added in version 2020.02.