role Metamodel::PrivateMethodContainer

Metaobject that supports private methods
role Metamodel::PrivateMethodContainer { ... }

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

In Raku, classes, roles and grammars can have private methods, that is, methods that are only callable from within it, and are not inherited by types derived by inheritance.

class A {
        # the ! declares a private method
        method !double($x) {
            say 2 * $x;
        }
        method call-double($y) {
            # call with ! instead of .
            self!double($y);
        }
    }

For the purposes of dispatching and scoping, private methods are closer to subroutines than to methods. However they share access to self and attributes with methods.

Methods

method add_private_method

method add_private_method($obj, $name, $code)

Adds a private method $code with name $name.

method private_method_table

method private_method_table($obj)

Returns a hash of name => &method_object

method private_methods

method private_methods($obj)

Returns a list of private method names.

method private_method_names

method private_method_names($obj)

Alias to private_methods.

method find_private_method

method find_private_method($obj, $name)

Locates a private method. Otherwise, returns Mu if it doesn't exist.

See Also

role Metamodel::AttributeContainer

Metaobject that can hold attributes

role Metamodel::C3MRO

Metaobject that supports the C3 method resolution order

role Metamodel::Documenting

Metarole for documenting types.

role Metamodel::Finalization

Metaobject supporting object finalization

role Metamodel::MethodContainer

Metaobject that supports storing and introspecting methods

role Metamodel::Mixins

Metaobject for generating mixins

role Metamodel::MROBasedMethodDispatch

Metaobject that supports resolving inherited methods

role Metamodel::MultipleInheritance

Metaobject that supports multiple inheritance

role Metamodel::Naming

Metaobject that supports named types

role Metamodel::ParametricRoleGroupHOW

Represents a group of roles with different parameterizations

role Metamodel::ParametricRoleHOW

Represents a non-instantiated, parameterized, role.

role Metamodel::RoleContainer

Metaobject that supports holding/containing roles

role Metamodel::RolePunning

Metaobject that supports punning of roles.

role Metamodel::Stashing

Metarole for type stashes

role Metamodel::Trusting

Metaobject that supports trust relations between types

role Metamodel::Versioning

Metaobjects that support versioning

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.