Menu

#102 typechecking resend w/ value dispatching

User_Reported
open
nobody
5
2012-11-27
2005-03-09
No

From a user:

I am using MultiJava and running into difficulties with
resend. I am
implementing a class with a function, drawItem( Item i,
int s ), which
can be specialed on both arguments. I want to
implement the following
functions (where BASIC and DETAIL are constants):
- drawItem( Item i, int s ) : the default case
- drawItem( Item i, int@@BASIC ) : outputs basic
view of an item
- drawItem( Item i, int@@DETAIL s ) : outputs
detailed view of an
item
- drawItem( final Item@Book b, int@@DETAIL s ):
outputs info
specific to books and then resends to
drawItem( Item i, int@@DETAIL s)

When I actually implement all four (simplied version at
the end of
this email) I get the following error when I compile:

The number or types of the arguments are not
compatible with a
resend to the directly overridden method. A
resend may only
target the same generic function as the caller.
[MultiJava]

Things work find if I either remove the resend or or
remove the
drawItem( Item i, int@@DETAIL s ) version.

public class Terminal
{
public static final int BASIC = 0;
public static final int DETAIL = 1;

public Terminal() {}

public void drawItem( Item i, int s )
{
System.out.println("item, int");
}

public void drawItem( Item i, int@@BASIC s )
{
System.out.println("item, BASIC");
}

public void drawItem( Item i, final int@@DETAIL s )
{
System.out.println("item, DETAIL");
}

public void drawItem( final Item@Book b, final
int@@DETAIL s )
{
this.resend( b, s );
System.out.println("Book, DETAIL");
}
}

Discussion


Log in to post a comment.