Re: [Vala] Methods/ctors overloading



Frederik escribió:
Andrés G. Aragoneses wrote:
Hello. I'm wondering if the difference between Vala and C# wrt
method/ctor overloading is intentional or is its real support planned in
the future? I ask this because I think it's a really important feature.
If not planned, I'd like to know if there would be interest in accepting
patched for it.

Thanks,

     Andres


It's intentional. Keep in mind that compiled Vala class libraries are
intended to be usable C class libraries as well. For example, function
names like

 my_class_new
 my_class_new_with_foo
 my_class_new_from_bar

are more self-explaining than

 my_class_new0
 my_class_new1
 my_class_new2


Makes sense.
But this problem is limited in scope: public methods of public classes.
So the approach I would propose would be less intrusive than just adding
method overloading that generate overkill names:

a) Make method overloading for non-public members be supported without
restrictions.
b) For public members, method overloading is supported but would
generate a warning if not decorated with an attribute like
[ExposeName("_with_foo")] (being with foo the suffix to add to the
function when exposing the function as a library).

How does that sound?

Thanks,

        Andres


I don't think that method/constructor overloading is an important
feature. It adds no additional value for the programmer. The only
drawback is that the programmer has to be more creative with respect to
method/constructor naming. And with clear naming it's more obvious which
method will be called than with method overloading.


Best regards,

Frederik




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