Re: [Vala] Few questions from complete vala begginer




On Oct 8, 2010, at 11:48 AM, pancake wrote:

On 10/08/10 15:47, vml arsis net wrote:
i'm currently testing vala if i could move some of my work done on Mono/c#
to it. but, i couldn't find any definitive information on few topics even
though i studied all documentation available before writing this mail.
even "NO WAY IN HELL" is acceptable answer as i'm just trying to find best
porting methods for some services i wrote. i'd simply adapt to what i can
do, mostly i already have some really ugly workarounds.

are any of these in future plans?
- extension methods
vala is a static language, you cannot add methods to objects at runtime. it takes
no sense, refactoring the code will make this feature unnecessary, can you
provide a example to argue this feature?

That's not exactly what an extension method is in C# (admittedly I have no idea of the implementation details 
though). Extension methods allow a static method to "pretend" to be a member of a class like so:

public static void foo(this Something bar) { ... }

The method can then be used elsewhere like:

bar.foo();

Assuming bar is a "Something".

This actually work work well in Vala, since it's how all of GObject works when you get down to the C 
implementation. You don't get access to private members of course, it's really just syntactic sugar and is 
probably nicer than passing the object to the first argument.

But to the OP, Vala doesn't currently support this.

-Nate




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