Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: X10 2.1.2
-
Fix Version/s: X10 2.2
-
Component/s: Language Specification
-
Labels:None
-
Number of attachments :
Description
In clause 18.1 of the latest language specification, the last paragraph states this
"Static variables in the class are available in the external code."
One thing needs to be clarified is the "how to" part. In native Java code, directly referring to the static field name works. However for C++ native code, a name mangling is needed for access the static variable. It may also be helpful to point out the C++ native code may not be portable due to the name mangling.
An example helps
"
import x10.compiler.Native;
public class t1
{
public static PI : double = 3.141592653589;
@Native ("c++", "cos((#1) * t1::FMGL(PI))")
@Native ("java", "java.lang.Math.cos((#1) * PI)")
static def test1(d:double) : double
public static def main (args:Array[String](1)) : void
{
val np:int = Place.MAX_PLACES;
val delta:double = 1.0/np;
ateach (p in Dist.makeUnique())
{ val angle: double = here.id()*delta; val o = new t1().test1(angle); x10.io.Console.OUT.println (here + "got "+o); } }
}
"
Issue Links
- depends upon
-
XTENLANG-2480
Type bounds do not play nice with coercions
-
Probably related problems.