1 // simply declare external functions
\r
2 func puts(str : char*) : void;
\r
4 // global context can contain functions,
\r
5 // structs, global variables and namespaces
\r
7 var global2 : double = 123.45;
\r
9 func globalFunc() : void {
\r
13 // structs and functions can be declared generic
\r
14 // by providing a list of placeholder typenames
\r
20 return this->t1 + this->t2;
\r
30 func generic1<A>(a1 : A, a2 : A) : A {
\r
34 // namespaces can contain everything that
\r
35 // the global context can
\r
45 // nested namespaces
\r
54 // implicit 'this' parameter, pointer to containing struct
\r
55 this->i3 = this->i1 * this->i2;
\r
57 // lookup is done hierarchically
\r
58 f1(v1); // this is basically N1::N2::f1(N1::N2::v1);
\r
59 N1::f1(N1::v1); // the rest becomes exactly what they say
\r
63 return this->i1 + this->i2;
\r
68 // these have the same type
\r
69 var s1 : N1::N2::S1;
\r
77 func main(argc : int, argv : char**) : int {
\r
78 var s1 : N1::N2::S1;
\r
79 var s2 : N1::N2::S1;
\r
83 s1.m1(s2.m1(s3.m1(89)));
\r
87 // one 'copy' is compiled for every unique instantiation
\r
88 var s4 : S1<int, long>;
\r
93 generic1<int>(1, 2);
\r
94 generic1<double>(3.4, 5.6);
\r