Hi Kirak,

I'm assuming that src_array was created at (here).

In the first example, the src_array that is modified is actually a copy 
of a copy - it is copied to here.next() in the first line and then again 
(to the same place).  Note that at(here) is _not_ a noop - it copies all 
variables in the closure environment!  This is to make the behaviour of 
the at statement consistent regardless of the target place.

The second example doesn't actually work for me, etiher (against SVN 
HEAD) - if I print the contents of src_array, they have not been 
updated.  Again, the src_array that is updated is a copy, so the updates 
don't affect the original src_array.

Have a look at the RemoteArray class and the Array.copy(...) and 
Array.asyncCopy(...) methods.  These support a variety of patterns of 
local and remote updates - hopefully one of them matches your requirement.

Cheers,

Josh

On 17/12/10 16:16, Kirak Hong wrote:
> Hi,
>
> I have another question regarding X10 array. I tried to modify a local array
> from remote place using following code. I noticed that there's some
> computation running, but the content of array was never changed.
>
>                          at(here.next())
>                          at(here)
>                          {
>                                  for(p in src_array)
>                                  {
>                                          src_array(p) = 10000;
>                                  }
>
>                          }
>
>                          for(p in src_array)
> Console.OUT.println(src_array(p));
>
> However, the following code seems to be working, although it is highly
> inefficient.
>
>                          at(here.next())
>                          for(p in src_array)
>                          {
>                                  var x : int = 0;
>                                  at(here)
>                                  {
>                                          x = 10000;
>                                  }
>                                  src_array(p) = x;
>                          }
>
> I looked at the X10 programming manual and it says it will implicitly copy
> an object to another place if that object is used within 'at' clause.
> However, I don't understand why above behavior happens. Can anybody tell me
> the reason?
>
> Thanks,
> Kirak
> ------------------------------------------------------------------------------
> Lotusphere 2011
> Register now for Lotusphere 2011 and learn how
> to connect the dots, take your collaborative environment
> to the next level, and enter the era of Social Business.
> http://p.sf.net/sfu/lotusphere-d2d
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>    


------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to