Hi there, Attached you can find a tryout for adding simple support for extension methods to valac. I'm nonetheless mailing this unfinished work to the mailing list for feedback already. Especially how I'm finding the Class to add the method to concerns me (I dislike the find_in_tree which I added to Namespace). I'm also unsure about just using add_method on the class, instead of adding a add_extension_method instead (and keeping the list separate). That or perhaps have a is_extension bool on Vala.Method? Right now the compiler will not use the parameter's identifier to refer to the this object. Instead only 'this' works. The Code writer must I guess also do something like TestA *a = this at the top of the function? The syntax that I'm aiming for is very much like extension methods in C#: public class Test { public void Existing() { } } public void Method (this Test a) { // a.Existing(); doesn't work yet this.Existing(); // works atm, but should use a here } Hoping for input and assistance from more experience Valac developers ;-) Kind regards, Philip -- Philip Van Hoof freelance software developer Codeminded BVBA - http://codeminded.be
Attachment:
0001-Adds-support-for-simple-extension-methods.patch
Description: Text Data