HaloO,

I wrote:
Yes, but I was conjecturing that the additions to A&B are pushed
down to A and B such that their intension sets remain strict supersets
of A&B.

Think of the Complex example that might read

  role Complex does Num & !Comparable
  {
      method im { return 0; }
      method re { return self as Num } # a no-op for Num
  }
  class Complex does Complex
  {
      has $.re; # accessor overwrites role method
      has $.im; # accessor overwrites role method
  }

Apart from the fact that the role and the class compete for the
same name slot this looks like what you need to make Num applicable
wherever a Complex is expected:

  module A
  {
     use Complex;
     Num $a;
     say $a.im; # statically type correct, prints 0
  }
  module B
  {
     Num $b;
     say $b.im; # syntactically admissible, but produces runtime error
  }

Actually the 'self as Num' should return the self type ::?CLASS to
preserve as much type information as possible. Hmm, could we get
the keyword Self for that?


Have a nice weekend, TSa.
--

Reply via email to