Re: [gtkmm] gtkmm 2.4 questions



On Wed, 2004-06-16 at 15:48 +0200, Frank Naumann wrote:
> Hello!
> 
> >> But another thing about CellRenderer. Is there any reason why
> >> get_size_vfunc is now 'const' ? This is IMHO a very bad idea as everybody
> >> who write it's own CellRenderer is very limited (especially if you
> >> dynamically calculate the cell content).
> >
> > I don't understand. If the method should not change the instance, then
> > the method should be const.
> 
> Yes, that is right.
> 
> > Do you think that this method should change the instance?
> 
> You know before that other developer want todo? Why you assume that 
> get_size_vfunc don't change the instance? If I see this right 
> Gtk::CellRenderer is supposed to be a base class for self defined 
> renderers. So you can't know before how what they like todo.

You would expect get_size() to be const. Therefore the implementation
should probably be const.

> > If you need to change member data without really changing the instance,
> > then you need to use the mutable keyword. Const is whatever you define
> > it to mean.
> 
> Adding tons of mutable keywords to most of my own instance data just to be 
> able to add the 'const' qualifier to lot of other private methods (that 
> are called by get_size_vfunc) is not a good style or solution. At least I 
> don't see a reason why this is good or better only to have get_size_vfunc 
> as const method.

I think it's better to make life difficult occassionally for someone
implementing one class than to make life dificult often for someone
using any of a set of classes.

-- 
Murray Cumming
murrayc murrayc com
www.murrayc.com





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