[comp.lang.eiffel] multi level generics

marcap@concour.CS.Concordia.CA (Marc Pawlowsky) (10/03/89)

I am trying to define an object with a constrained generic type.  And the 
constrained type has a gneric type in its definition.  For example:

class A[U]

export
  contents

feature
  contents: U;

  Create(x:U) is
    do
      contents := x;
    end; -- Create

end -- A


class B[R->A]

feature
  b_contents:R;

  Create(x:R) is
    do
      b_contents := x;
    end; -- Create

  rout1 is
    local
      dummy:R;
    do
      dummy := b_contents.contents;
    end; -- rout1

end -- B

Trying to compile this (adam% is my prompt) gives:

adam% adam% ec b
Pass 1 on class b
Pass 2 on class b
        Interface may have changed.
Pass 3 on class b
"b", 15: Incorrect number of actual generic parameters for class a
*** ec: pass3 failed 
Stop.
adam% 

Please note that the error is at the line 'dummy := ...'.
OK This makes sense, so lets change the contents of class B.  
Unfortunately the obvious solution is: 


   class B[R->A[S]]

Trying to compile gives:

adam% ec b
Pass 1 on class b
"b", 1: Cannot find supplier class: s
*** ec: pass1 failed 
Stop.
adam% 

Which is what it is supposed to do according to the Eiffel syntax.

At this point I'm stumped.  Does anybody know what to do?

I'm working in Eiffel 2.1 on a Sun 3/50 under Unix 3.50 (Export)

Marc Pawlowsky
Graduate Student
Concordia University