On 10/19/05, Stevan Little <[EMAIL PROTECTED]> wrote:
> Darren,
> Your problem reminds me of the "Expression Problem", which is
> something that IIRC Luke's Theory idea was trying to solve.

Indeed, this problem is almost exactly the contravariant half of the
expression problem.  Once upon a time, a theory was supposed to
represent your "role AB", but it has diverged from that.  Nowadays I
think a problem like this solved by deriving from a module, which
isn't too unlike what you were showing.  The "factory" abstraction
from the theory proposal solves the well-typedness of this kind of

Here's a guess:

  module AB;

  class A {
    submethod one () {
      return 'hello';

    submethod two () {

  class B {
    submethod three () {

    submethod four () {
      return 'here';

  module CD;
  is AB;

  class A is AB::A {
    submethod one () {
      return 'world';

  class B is AB::B {
    submethod four () {
      return 'there';

This is treating all names in a module as virtual.  There may be a
downside to this, in which case we could go Scala's direction and make
the distinguishing property of a role (there called "trait") that the
things it declares are virtual.

However, if you're ever deriving from a module, a somewhat uncommon
thing to do, supposedly you're doing so precisely to make the names
virtual like this.  So this may just be the right solution.


Reply via email to