[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*          gtk_button_new                      (void);
GtkWidget*          gtk_button_new_with_label           (const gchar *label);
GtkWidget*          gtk_button_new_with_mnemonic        (const gchar *label);
GtkWidget*          gtk_button_new_from_stock           (const 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.

-- 
Regards.
Martin


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