Re: [Vala] Friend class?



On Tue, 2009-03-10 at 08:25 +0700, Hans Baier wrote:
2009/3/10 Yu Feng <rainwoodman gmail com>:
Dear list,

Are friend classes available in VALA? If not, are there any particular
reason against it, and are there any alternatives for friend classes?

Regards,

Yu

If you need friend classes, you should probably redesign the code.

Yes. This is what I guessed for the reason why friend classes are not
popular. Would you give me some advices?

What do you need them for?

I have a class (Track) that calls Gsl for solving ODEs. Gsl requires
several callbacks which don't look vala. 

Keeping them in the same source file makes the Track class clumsy.
Therefore I am leaning to move those callbacks to another class, which
is privately called and internally used by Track.

The issue arises here. The moved code modifies some obviously private
members of Track. I remember friend classes is invented for doing this.

An alternative would be declaring the new class as a private child-class
inside Track. However that doesn't help cleaning up the source code file
since the child-class has to reside in the same file.

Best,

Yu




Hans




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