Kshitij Mehta <kvm1...@gmail.com> wrote on 12/06/2009 06:27:48 PM: > Hello > I am running an x10 1.7 application using the java backend. I am using > a block distribution on an array and I get a badplaceexception when i > use ateach on the array. I understand this is caused when i try to > access an array value that resides on another place. Can someone show > a small example on how to fix it? Please note that I cannot make the > array a val object, it has to be a 'var'.
Hi, Kshitij, If by "val object" you mean a "value class", then that's not relevant, but if you mean a variable declared as "val", you can always create an immutable copy of any variable. If you capture a var (mutable) variable in an ateach body, you will get a BadPlaceException when trying to access that variable. The type checker should prevent this, but there were some known bugs in X10 that allowed such capture. The idiom for creating an immutable copy of a variable is: var x: T; ... val y: T = x; ateach (...) { ... use y here ... } Please let us know if that solves your problem. Also, if the type checker allowed you to capture a var in an ateach body, please report a bug through JIRA. 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/) ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users