Hello, yes, toString is global. However, this problem has nothing to do 
with toString.

However, a is a DistArray. a(point) attempts to access the point'th 
location of a. This location, per the distribution yu gave when you 
created the DistArray, is not located at the place where you are 
performing the access.

Hence you get a BadPlaceException.

Hope this helps,
Best,
Vijay

李伟 wrote:
> Hi:
>
> I've written a x-10 problem as follows:
>
> public class Fun2
> {
>  public static def main(argv:Rail[String]!) =
>  {
>      val a : DistArray[Int]
>              =
> DistArray.make[Int](Dist.makeBlock(1..35),((i):Point)=>i*i);
>      x10.io.Console.OUT.println(str(a));
>  }
>
>  static def str[T](a:DistArray[T]):String  {
>      var s : String = "";
>      var first : Boolean = true;
>      for(point in a)
>      {
>       if (first) first = false;
>       else s += ",";
>       s += a(point).toString();
>      }
>      return s;
>  }
> }
>
> It can be compiled. And when running, the program crashed. The output info
> is as follows:
>
> x10.lang.BadPlaceException: point (10) not defined at (Place 0)
>  at x10.array.DistArray$2.apply(DistArray.java:613)
>  at x10.array.DistArray$2.apply(DistArray.java:1)
>  at x10.array.BaseRegion.check(BaseRegion.java:120)
>  at x10.array.DistArray.checkPlace(DistArray.java:1407)
>  at x10.array.DistArray.apply(DistArray.java:998)
>  at Fun2.str(Fun2.java:149)
>  at Fun2.main(Fun2.java:106)
>  at Fun2$Main$2.apply(Fun2.java:51)
>  at x10.lang.Runtime$5.apply(Runtime.java:4454)
>  at x10.lang.Activity.run(Activity.java:217)
>  at x10.lang.Runtime$Worker$3.apply(Runtime.java:3455)
>  at x10.runtime.impl.java.Runtime.runAt(Runtime.java:105)
>  at x10.lang.Runtime$Worker.loop(Runtime.java:3422)
>  at x10.lang.Runtime$Worker.apply(Runtime.java:3308)
>  at x10.lang.Runtime$Pool.apply(Runtime.java:3842)
>  at x10.lang.Runtime.start(Runtime.java:4461)
>  at Fun2$Main.main(Fun2.java:34)
>  at x10.runtime.impl.java.Runtime.run(Runtime.java:50)
>  at java.lang.Thread.run(Unknown Source)
>
> When changing the sentence:
> s += a(point).toString();
> into the new form:
> s += at(a.dist(point)){a(point).toString()};
> it runs well.
>
> In my opinion, toString is global. And therefore I don't need to use the
> "at" clause. Are there any problems here?
>
> Best regards,
> Wei Li
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate 
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
> lucky parental unit.  See the prize list and enter to win: 
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
>
>
>   




------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate 
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the 
lucky parental unit.  See the prize list and enter to win: 
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to