On Jun 7, 2006, at 10:06 AM, Lars Jensen wrote:
Are you sure there is no way to achieve this by having some methods
extending some interface?
That's a good point; this is how one makes mix-in classes in RB.
It's possible that whatever functions Lars wants to add to his
various list classes, could be implemented as a mix-in.
Some could, some couldn't. For example:
Class FooList
public Item(i as integer) as Foo
public MaxIndex as integer
If for all similar list classes I wanted a Count function, which is
the maximum index plus one, I could define an Interface and an
extension method that implemented it. But the Item function couldn't
work that way. The point stands that RB has no way to specify a
"placeholder" for a type, which is what I believe would allow a
general solution to the problem that Joe brought up.
Actually, that's not quite true in your example above. Return type
covariance allows subclasses or interface implementors to implement a
method specifying a more specific type as the return type. For example,
if the interface defined the Item method as "Item(i as Integer) as
Object", the implementation could be "Item(i as Integer) as Foo". This
would satisfy the interface's contract, as Foo IsA Object.
However, for types of parameters, the problem still remains.
HTH,
Jon
--
Jonathan Johnson
REAL Software, Inc.
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>