[Vala] overload tricks



Hi:

Several weeks ago i post a questions about overload functions in VALA. I want create a wiki page with substitute methods in VALA for this topic:

1)))  OVERLOAD FUNCTIONS 1:
You can use default values for parameters:

void method (int param1 = 5, string param2 = "x", bool param3 = false) {
        ...
}


then you can call

method ();
method (6);
method (6, "y");
method (6, "y", true);

this is perfect to emule Visual basic parameters for example.


2))) OVERLOAD CONSTRUCTOR.

GtkWidget <http://library.gnome.org/devel/gtk/stable/GtkWidget.html>*          gtk_button_new 
<http://library.gnome.org/devel/gtk/stable/GtkButton.html#gtk-button-new>                      (void);
GtkWidget <http://library.gnome.org/devel/gtk/stable/GtkWidget.html>*          gtk_button_new_with_label 
<http://library.gnome.org/devel/gtk/stable/GtkButton.html#gtk-button-new-with-label>           (const gchar 
<http://library.gnome.org/devel/glib/stable/glib-Basic-Types.html#gchar> *label);
GtkWidget <http://library.gnome.org/devel/gtk/stable/GtkWidget.html>*          gtk_button_new_with_mnemonic 
<http://library.gnome.org/devel/gtk/stable/GtkButton.html#gtk-button-new-with-mnemonic>        (const gchar 
<http://library.gnome.org/devel/glib/stable/glib-Basic-Types.html#gchar> *label);
GtkWidget <http://library.gnome.org/devel/gtk/stable/GtkWidget.html>*          gtk_button_new_from_stock 
<http://library.gnome.org/devel/gtk/stable/GtkButton.html#gtk-button-new-from-stock>           (const gchar 
<http://library.gnome.org/devel/glib/stable/glib-Basic-Types.html#gchar> *stock_id);

How can we emule this topic in VALA:
http://www.vala-project.org/doc/references/gtk+-2.0.vapi/Gtk/Button.htm

This VALA button i think it´s a good example. Any samples to the wiki??


This is necessary for many classes like a "circle" class. We can create a circle by different kind of parameters (radius+center, 3 points, etc).


3))) OVERLOAD TYPES OF PARAMETERS

int find(int colum, table A, int value) int find(int colum, table A, long value) int find(int colum, table A, string value)
How can we find a value in table if we have different kinds of column types.
Perhaps here we don´t have any solution, or perhaps using pointers.

Attachment: martin_gnu.vcf
Description: Vcard



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