Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Elaborate a bit on the MOP
  • Loading branch information
moritz committed Jan 24, 2015
1 parent f84804e commit 2cfdaf6
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
34 changes: 34 additions & 0 deletions lib/Language/mop.pod
Expand Up @@ -102,4 +102,38 @@ The presence of a C<Scalar> object indicates that the object is "itemized".
say (1, 2, 3).VAR ~~ Scalar; # False
say [1, 2, 3].VAR ~~ Scalar; # True
=head1 Structure of the meta object system
B<Note:> this documentation largely reflects the meta object system as
implemented by the L<Rakudo Perl 6 compiler|http://rakudo.org/>, since the
L<design document|http://design.perl6.org/> are very light on details.
For each type declarator key word, such as C<class>, C<role>, C<enum>,
C<module>, C<package>, C<grammar> or C<subset>, there is a separate meta
class in the C<Metamodel::> namespace. (Rakudo implements them in the
C<Perl6::Metamodel::> namespace, and then maps C<Perl6::Metamodel> to
C<Metamodel>).
Many of the these meta classes share common functionality. For example roles,
grammars and classes can all contain methods and attributes, and can do roles.
This shared functionality is implemented in roles which are composed into the
appropriate meta classes. For example
L<role Metamodel::RoleContainer|/type/Metamodel::RoleContainer> implements the
functionality that a type can hold roles, and
L<Metamodel::ClassHOW|/type/Metamodel::ClassHOW>, which is the meta class
behind the C<class> keyword, does this role.
=head2 Bootstrapping concerns
You might wonder how C<Metamodel::ClassHOW> can be a class, when being a class
is defined in terms of C<Metamodel::ClassHOW>, or how the roles responsible
for role handling can be roles. The answer is I<by magic>.
Just kidding. Bootstrapping is implementation specific. Rakudo does it by
using the object system of the language in which itself is implemented, which
happens to be (nearly) a subset of Perl 6: NQP, Not Quite Perl. NQP has a
primitive, class-like kind called C<knowhow>, which is used to bootstrap its
own classes and roles implementation. C<knowhow> is built on primitives that
the virtual machine under NQP provides.
=end pod
3 changes: 2 additions & 1 deletion lib/Language/objects.pod
Expand Up @@ -621,6 +621,7 @@ To get rid of using the same object twice, there is a shortcut:
say 1.HOW.name(1); # Int
See L<Metamodel::ClassHOW|/type/Metamodel::ClassHOW> for documentation of
the meta class of C<class>.
the meta class of C<class>, and also the L<general documentation on the meta
object protocol|/language/mop>.
=end pod

0 comments on commit 2cfdaf6

Please sign in to comment.