On 14/10/2013 17:56, Philip Van Hoof wrote:
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 ;-)
Thanks for your contribution :-)
A couple of points:
1) Patches/feature requests go to bugzilla, unless you want them to be
forgotten and eaten by the darkness :) IIRC there's already a bug about
that.
2) Instead of defining methods without a class scope and
special-casing/altering the syntax of parameters, I'd suggest either:
extend class Test {
public void method () { }
}
which adds a namespacing and makes the method look like more an instance
method in its usage and definition.
or:
[Extend]
public void method (Test this) {
}
_______________________________________________
vala-list mailing list
vala-list@gnome.org
https://mail.gnome.org/mailman/listinfo/vala-list