Evan Laforge wrote:

> Well, unless I'm misunderstanding, this whole thing is about evil
> upcasts, right?  You have a widget and you want to cast it to a group
> and do group things to it. 

You're absolutely right.

> So currently it's:
> 
> if (w.type() == xyz) { g = (Fl_Group) w ...
> 
> If I understand the proposal, that would make
> 
> if (w.is_group()) { g = (Fl_Group) w ...
> 
> So why not put the cast in the method:
> 
> if (Fl_Group *g = w.as_group()) { ...

In fact I had also considered this - although I would have
called it is_group() anyway. Using the pointer return value
like a boolean is okay, and doing the cast in the function
is an additional gain. Thus, we could also declare

   virtual Fl_Group *Fl_Widget::is_group() const;
   virtual Fl_Window *Fl_Widget::is_window() const;

BTW. I omitted the additional const intentionally, but I would
have added it in the real declaration.

The reason why I did not propose it this way was the similarity
with the FLTK 2 methods (replacing bool with int only), so that
it would be easier to merge the code in FLTK 3 ;-)

But I'm open for both, and if there wasn't FLTK 2 I would also
have proposed the pointer return value. Maybe we should do
what is best for the code (i.e. return the pointer) and don't
look at FLTK 2 at all. Or we could also do both...

Albrecht
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to