Re: [Felix-language] Functions in structs

2012-03-05 Thread john skaller
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

Re: [Felix-language] Functions in structs

2012-03-04 Thread john skaller
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.

Re: [Felix-language] Functions in structs

2012-03-04 Thread john skaller
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; //

[Felix-language] Functions in structs

2012-03-04 Thread john skaller
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 (