[Gtk-sharp-list] Method overloading in some classes

Christopher Armstrong quineska@gamebox.net
Wed, 23 Mar 2005 22:22:15 +1100


I am new to this list, and what I am saying below has been posted on
bugzilla (bug #73876 - http://bugzilla.ximian.com/show_bug.cgi?id=73876)

I am using version 1.0 of the libraries in the latest release (the
release version 1.9.2), not the versioned "2.0" libraries (which I think
are supposed to be something like 1.9.2).

My problem is with the use of the Visual Basic compiler (.NET version)
on Windows with GTK#. I can reference the libraries, I can load a glade
file with an interface, and I can autoconnect the glade file to my
instance variables of the same name. This seems to work almost
flawlessly.

My problem is with some of the methods in the TreeStore class. Most of
the list add/remove/insert type methods have been overloaded, C# syntax
of the prototypes as follows:

Append methods:
TreeIter Append(TreeIter);
void Append(out TreeIter);

Insert methods:
TreeIter Insert(TreeIter, int);
void Insert(out TreeIter, int);

This is fine in C#, where the compiler can distinguish between your use
of which overloaded method by your use of the "out" keyword.
Unfortunately, Visual Basic does not have such a keyword, and
automatically passes by reference or by value as to what the prototype
tells it. As a result it gives a "function overload error", essentially
saying that it cannot tell which method you are calling (even using the
"Call" keyword, which assumes the method returns "Nothing"/"null" is not
enough to force it to use the "void" overload).

The only solution I can think of is to 
a) use reflection to get the method you want (cumbersome, undesirable)
b) use C# (this is what I've had to do, seperating my code out into a VB
library and rewriting my GUI in C#, where I would have just rewritten in
VB as I planned to anyway. I was rewriting my GUI from Windows.Forms so
I could use the Gecko control accross platforms).

I know this may not be high priority (considering we are talking of
Visual Basic here :-( ), but I do believe this could be a problem for
users in the future.


-- 
Christopher Armstrong <quineska@gamebox.net>