Your code seems fine to me :)

Your code compiles for me on the C++ backend and runs correctly:
Yoav@YoavLaptop ~/test
$ x10c++ Hello.x10

Yoav@YoavLaptop ~/test
$ runx10 a.exe
100000



but I have a post-compilation error in Java:
$ x10c Hello.x10
    : ----------
     1. ERROR in C:\cygwin\home\Yoav\test\Hello.java (at line 143)

((x10.core.GlobalRef<java.lang.Integer>)t1$b).$set$G((int)($t141[0]=100000));
         ^^^^
     t1$b cannot be resolved
     ----------
     1 problem (1 error)
1 error.

I've opened a Jira for it (you can follow it and see when it's resolved):
http://jira.codehaus.org/browse/XTENLANG-2365


As a work around, refactor your code so that the async-initialization of t1
happens in another method (that compiles on the java backend):


public class Hello {
    public static def main(argv:Array[String](1)) {
        var t0 : Int = 0;
        val val_here = here;
        finish{
            at(here.next()) {
                val t1 : Int = calcT1();
                at (val_here){ atomic { t0 = t1; } }
            }
        }
        Console.OUT.println(t0);
    }
    public static def calcT1() {
        val t1 : Int;
        finish{
            async { t1 = 100000; }
        }
        return t1;
    }

}


On Mon, Jan 24, 2011 at 1:12 AM, AmAnLyNn <amanl...@gmail.com> wrote:

> I m a beginner to write X10 program and I have a question about place and
> async.
>
> I want an activity to do some calculation at other place, and then return
> the result back to the main fuction. But I cannot write the code
> successfully and I have read the userguide. Could u please give me an
> example? Here is my code pieces:
>
> var t0 : Int = 0;
> val val_here = here;
> finish{
>        at(here.next()) {
>                val t1 : Int;
>                finish{
>                         async { t1 = 100000; }                 // here is
> to do some calculation at other place
>                }
>                at (val_here){ atomic { t0 = t1; } }          // when all
> calculation is over, return the result from other place
>                }
>        }
>
> I think x10 should support such requirement, please help me
>
>
>
> --
> Amanlynn
>
> ------------------------------------------------------------------------------
> Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
> Finally, a world-class log management solution at an even better
> price-free!
> Download using promo code Free_Logger_4_Dev2Dev. Offer expires
> February 28th, so secure your free ArcSight Logger TODAY!
> http://p.sf.net/sfu/arcsight-sfd2d
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to