HaloO,

Jonathan Lang wrote:
TSa wrote:
 > Dispatch depends on a partial ordering of roles.

Could someone please give me an example to illustrate what is meant by
"partial ordering" here?

In addition to Matt Fowles explanation I would like to
give the following example lattice build from the roles

  role A { has $.x }
  role B { has $.y }
  role C { has $.z }

There can be the four union combined roles A|B, A|C, B|C
and A|B|C which complete the type lattice:

                     Any={}
                    /  |  \
                   /   |   \
                  /    |    \
                 /     |     \
                /      |      \
              A={x}  B={y}  C={z}
               | \    / \    / |
               |  \  /   \  /  |
               |   \/     \/   |
               |   /\     /\   |
               |  /  \   /  \  |
               | /    \ /    \ |
         A|B={x,y} A|C={x,z} B|C={y,z}
                \      |      /
                 \     |     /
                  \    |    /
                   \   |   /
                    \  |  /
                A|B|C={x,y,z}

Note that A = (A|B) & (A|C) is the intersection type of A|B and A|C.
Note further that A|B is a subtype of A and B written A|B <: A and
A|B <: B and so on. Usually the A|B|C is called Bottom or some such.
I think it is the Whatever type of Perl6. It is the glb (greatest lower
bound) of A, B and C. In a larger lattice this type gets larger as well.
Any is the trivial supertype of all types.

This lattice can then be used for type checks and specificity
comparisons in dispatch. BTW, such a lattice can be calculated lazily
from any set of packages. In pure MMD the selected target has to be
the most specific in all dispatch relevant positions.

Regards,
--

Reply via email to