Re: [Vala] Extension Methods



What about this:

public extend class Gtk.Widget {
    public bool set_gl_capability (GdkGl.Config glconfig,
Gdk.GlContext? share_list, bool direct, int render_type) {

      // do stuff.
    }
}

AKA, when vala encounters the extend keyword, instead of panicing
duplicated class declarations, it simply add the decleration to the
existing class.

This requires to make use of the 'extern' flag on the members declared
in vapi files, because now a class can span over multiply source
files, mixing imported and implemented methods in .vapi and .vala
files.

Should someone file a bug in bz?

Yu


On Sat, Mar 7, 2009 at 3:31 PM, Sam Danielson <samdanielson gmail com> wrote:
2009/3/6 Uwe Strempel <u strempel googlemail com>:
Hi,
yes you are right.
C# 3.0 syntac for inner-type declaration is not the best.

This syntax:
       public int string.count_words() {
               return this.split_set(" .?").length;
       }
might be better.
Thanks,
regards
Uwe

That would be really nice for when subclassing is unavailable, like
when the object is returned by an external library. I've been editing
the vapi file to add convenience methods to Sqlite.Statement. I
suppose you could do the same with the glib-2.0.vapi. Without the
ability to patch static methods we are encouraged to hack the vapi's,
which hurts standardization. All for the love of syntax sugar :).

-Sam Danielson
_______________________________________________
Vala-list mailing list
Vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]