Dave Hudak <dhu...@osc.edu> wrote on 07/28/2010 02:37:22 PM: > Hi All, > > I am trying to write a class that will do a prefix sum on an array. I > have written the single-place version and a single-place version that > uses multiple activities to compute the sums. I am now trying to > write the distributed version. Both classes are included (I will > eventually write an interface for these classes). > > I have been able to write the constructors and call them without run- > time exceptions occurring. Now, I want to write a function that > returns a single string representation of a dist array. I wrote a > function that should create a string representation of all dist array > elements at a given location (I called it place_str), and then I want > to loop over all places: > > (from DistPrefixSum.x10): > > public def str():String > { > var s : String = ""; //var is mutable > for (var place_id:int=0; place_id<Place.MAX_PLACES; place_id++) { > s += at (Place.places(place_id)) place_str(); > if (place_id != (Place.MAX_PLACES - 1)) { > s += ", "; > } //if > } //for i > return s; > } > > My error occurs on the at statement: > > dhu...@oscnet166 35%> x10c++ -O -o Driver Driver.x10 PrefixSum.x10 > AsyncPrefixSum.x10 DistPrefixSum.x10 > /Users/dhudak/osc/research/x10/tutorial/examples/GoodPrefixSum/src/DistPrefixSum. > x10:49: Local variable "place_id" is accessed from an inner class or a > closure, and must be declared final or shared. > 1 error. > > Does anyone have any recommendations? Creating a single string from a > dist array of integers is a reduction just like finding the sum or max > of the entries, so I figure its well understood...
Dave, This is a bug in the typechecking of at expressions. You can work around this by changing the body of the for loop to val z = new Cell[String](null); val h = here; at (Place.places(place_id)) { val q = place_str(); at (h) z.set(q); } s += z(); if (place_id != (Place.MAX_PLACES - 1)) { s += ", "; } //if The above code is less efficient, but it should work. I've opened a JIRA issue: http://jira.codehaus.org/browse/XTENLANG-1632 . Please watch that issue for updates on the fix. Igor -- Igor Peshansky (note the spelling change!) IBM T.J. Watson Research Center X10: Parallel Productivity and Performance (http://x10-lang.org/) XJ: No More Pain for XML's Gain (http://www.research.ibm.com/xj/) "I hear and I forget. I see and I remember. I do and I understand" -- Confucius ------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm _______________________________________________ X10-users mailing list X10-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/x10-users