Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
start to document ClassHOW
- Loading branch information
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| =begin pod | ||
| =TITLE class Metamodel::ClassHOW | ||
| =SUBTITLE Meta class for for classes. HOW circular. | ||
| class Metamodel::ClassHOW | ||
| does Perl6::Metamodel::Naming | ||
| does Perl6::Metamodel::Documenting | ||
| does Perl6::Metamodel::Versioning | ||
| does Perl6::Metamodel::Stashing | ||
| does Perl6::Metamodel::AttributeContainer | ||
| does Perl6::Metamodel::MethodContainer | ||
| does Perl6::Metamodel::PrivateMethodContainer | ||
| does Perl6::Metamodel::MultiMethodContainer | ||
| does Perl6::Metamodel::RoleContainer | ||
| does Perl6::Metamodel::MultipleInheritance | ||
| does Perl6::Metamodel::DefaultParent | ||
| does Perl6::Metamodel::C3MRO | ||
| does Perl6::Metamodel::MROBasedMethodDispatch | ||
| does Perl6::Metamodel::MROBasedTypeChecking | ||
| does Perl6::Metamodel::Trusting | ||
| does Perl6::Metamodel::BUILDPLAN | ||
| does Perl6::Metamodel::Mixins | ||
| does Perl6::Metamodel::ArrayType | ||
| does Perl6::Metamodel::BoolificationProtocol | ||
| does Perl6::Metamodel::REPRComposeProtocol | ||
| does Perl6::Metamodel::InvocationProtocol | ||
| does Perl6::Metamodel::Finalization | ||
| { } | ||
| C<Metamodel::ClassHOW> is the meta class behind the C<class> keyword. | ||
| say so Int.HOW ~~ Metamodel::ClassHOW; # True | ||
| say say Int.^methods(:all).pick.name; # sin | ||
| =head1 Methods | ||
| =head2 method add_fallback | ||
| method add_fallback(Metamodel::ClassHOW:D: $condition, $calculator) | ||
| Installs a method fallback, that is, add a way to call methods that weren't | ||
| statically added. | ||
| Both C<$condition> and C<$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 C<$condition> returns a true value, | ||
| C<$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 C<$conditon> returns a false value, the | ||
| next fallback (if any) is tried, and if none matches, an exception | ||
| L<of type X::Method::NotFound|/type/X::Method::NotFound> is thrown. | ||
| User-facing code (that is, ,code not dabbling with meta classes) should use | ||
| method C<FALLBACK> instead. | ||
| =end pod |