The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
=pod

=head1 NAME

10,000 ft view of the Perl6 MetaModel (2.0)

=head1 DISCLAIMER

It should be noted that version 2.0 of the Metamodel is not yet 
complete, and is still missing some core features. However it
currently does have the base elements needed to support those
additional features. This document describes the current state
of the metamodel, so it I<will> change. 

=head1 NOTATIONAL CONVENTIONS

    i(Foo)     - instance of Foo
    class(Foo) - the instance of Class named "Foo"

=head1 DESCRIPTION

Here is the basic layout of the metamodel 2.0 (in ASCII art). 
    
            <user space>                  <meta space>
    -----------------------------------------------------------
                                  :  
          +---------------+       :  
          | i(Foo)        |       :  
          +---------------+       :  
          | class         |----+  :  
          | instance_data |    |  :    
          +---------------+    |  :    
                               |  :     
    +--------------------------+  :         
    |                             :  
    |     +---------------+       :     +---------------+     
    +---->| class(Foo)    |   +---:---->| class(Class)  |<---+
          +---------------+   |   :     +---------------+    |
          | class         |---+   :     | class         |----+
          +---------------+       :     +---------------+   
          | name          |       :     | name          |   
          | version       |       :     | version       |   
          | authority     |       :     | authority     |   
          | %methods      |       :     | %methods      |   
          | %attributes   |       :     | %attributes   |   
          | ...           |       :     | ...           |     
          +---------------+       :     +---------------+     
                                  :  

=head1 BOOTSTRAPPING

This is a rough description of the bootstrapping process. It follows the 
files which are loaded, and what those files do.

=over 4

=item I<chaos.pl>

This file contains all the primitive elements needed for the meta-model
including global functions (C<WALKMETH>, C<WALKCLASS>, etc.), method 
generators, tagged attribute types, and opaque instance creators.

This is also where the Perl 5 magic exists to allow for "normal" method 
dispatching behavior.

=item I<gnosis.pl>

This file creates a the basic class C<$::Class> manually, and then adds the
C<add_method> function to it. This is the very first "object" in our system
and after this is loaded, we can actually start using it as such.

=item I<metamorph.pl>

This fills in the remaining methods in C<$::Class>, each method giving 
C<$::Class> more and more capabilities. It also then defines the attributes
of C<$::Class>. 

Once this file is loaded, we have a fully formed class C<$::Class>, however
it is not over yet.

=item I<pneuma.pl>

This file constructs C<$::Object> using the same tools used in F<gnosis.pl> 
and F<metamorph.pl>. 

=item I<genesis.pl>

This file connects C<$::Class> to C<$::Object> by adding C<$::Object> to 
C<$::Class>'s superclass list. We also manually populate the MRO's of both 
classes to avoid meta-circularity issues. 

We now have a working object model, and at this point, the following things 
are true:

    class($::Class) is an instance of $::Class
    class($::Object) is an instance of $::Class
    $::Class is a subclass of $::Object

Or represented visually here:

    ---> is subclass of
    ...> is instance of

       class($::Class)
           :     ^
           :     :
           V     :
          $::Class ------+
              ^          |
              :          |
              :          |
      class($::Object)   |
              ^          |
              :          |
              :          |
         $::Object <-----+    

=item I<Perl6::MetaModel>

This package loads all the other files above, and then provides what I 
am calling a "macro" layer to make class construction easier. This layer
will likely be handled by the language parser in a real implementation, 
but is here purely for prototyping/testing convenience. 

=back

=head1 AUTHOR

This basically means that anything incorrect in here is my fault.

Stevan Little E<lt>stevan@iinteractive.comE<gt>

=cut