On 05/03/2012, at 12:57 PM, john skaller wrote:
> Ok, so this now works:
>
> //
> struct X {
> a:int;
> b:double;
> fun f (x:int) => self.a + x + x;
> fun g => self.a;
> proc s (x:int) => self.a = x;
> };
So now I am thinking: what if we implemented *real* C++ methods?
It comes close
And now we have polymorphism..
///
struct X[t] {
a:int;
b:double;
c:t;
fun f (x:int) => self.a + x + x;
fun g => self.a;
proc s (x:int) => self.a = x;
fun cc => self.c,self.c;
fun cx[u] (q:u) => self.c,q;
};
var x = X (1,2.0, "Hi");
println$ x.a, x.b, f x 42, g x;
println$ x.
Ok, so this now works:
//
struct X {
a:int;
b:double;
fun f (x:int) => self.a + x + x;
fun g => self.a;
proc s (x:int) => self.a = x;
};
println "Blah";
var x : X = X (1,2.0);
println$ x.a, x.b, f x 42, g x;
println$ x.a, x.b, x.f 42, x.g;
&x.s 5;
println$ x.a, x.b, x.f 42, x.g;
//
You can now do this:
struct X {
a:int;
b:double;
fun f (x:int) => self.a + x + x;
fun g => self.a;
};
var x : X = X (1,2.0);
println$ x.a, x.b, f x 42, g x;
println$ x.a, x.b, x.f 42, x.g;
At present:
* Polymorphism isn't supported.
(coming)
* It must be a Felix function (