Jim LaGrone <[email protected]> wrote on 07/28/2009 12:04:21 PM:

> I have this code
> 
>       val array3d = Array.make[double](R);
> 
>       for (j = 0; j < 10; j++)
>          for (k = 0; k<edge_size; k++)
>             for (l = 0; l < edge_size; l++){
>                array3d.set(0.0, 1,j,(k+l*edge_size));
>             }
> 
> returning this compiler error
> 
> Method set(T, x10.lang.Int, x10.lang.Int, x10.lang.Int) 
> {x10 
> .lang 
> .Array 
> #this.x10.lang.Array#dist.x10.lang.Dist#region.x10.lang.Region#rank==3} 
> [] in x10.lang.Array[x10.lang.Double] cannot be called with arguments 
> (x10.lang.Double{self==0.0}, x10.lang.Int{self==1}, x10.lang.Int, 
> x10.lang.Long); Call invalid; calling environment does not entail the 
> method guard.
> 
> Can someone tell me what the method guard is and how to use it? I'm 
> looking at this in Array.x10:
> 
>      public abstract safe def apply(pt: Point(rank)): T;
>      public abstract safe def apply(i0: int) {rank==1}: T;
>      public abstract safe def apply(i0: int, i1: int) {rank==2}: T;
>      public abstract safe def apply(i0: int, i1: int, i2: int) 
{rank==3}: T;
>      public abstract safe def apply(i0: int, i1: int, i2: int, i3:int) 
{rank==4}: T;

Hi, Jim,

The method guard in the above is {rank==3} (for the method you
were trying to invoke).  The array object returned by Array.make
inherits its rank from the region used to construct it (i.e., R).
If you show us how R was declared and computed, we could figure
out whether this is a bug or expected behavior.

I suspect you declared R as

    val R: Region = ...;

which strips away the constraints on the type.  You can either
remove the type altogether, or add a constraint, e.g.,

    val R: Region{rank==3} = ...;

or

    val R: Region(3) = ...;

FWIW, I think your other problem is that the last argument to
set is a Long, rather than an Int.  I'm not sure you'll get an
implicit coercion in that case, so you might still have a type
error even after you fix the method guard problem.
        Igor
-- 
Igor Peshansky  (note the spelling change!)
IBM T.J. Watson Research Center
XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/)
X10: Parallel Productivity and Performance (http://x10.sf.net/)


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
X10-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to