Hello from an interested onlooker (and sole developer of an obscure FLTK2 
fork); hopefully you don't mind (tell otherwise) me joining in with a few 
thoughts.

Matthias Melcher wrote:
[...]
> At first I thought that the fltk2 naming is so much better, and it is
> for classes, but the global function names are inconsistent and
> annoying.
[...]
> Now, with some functions, especially the drawing functions, I am very
> unhappy, and the warning about using "using namespace fltk3" suddenly
> makes much more sense.
[...]
> Any suggestions on how the global function naming should be in FLTK3?
>
>
> - Matthias=
>

One suggestion for you all to consider: Keep the simple, consistent naming and 
then put /all/ global functions (and perhaps also constants) into an extra, 
inner namespace, given a short name so as to be bearable to type out. (for 
example, the "Fl" of FLTK1)

Then carefully document that doing "using namespace ..." on this inner 
namespace is unsupported and may cause naming collisions.

This would be functionally much the same as prefixing all those functions (and 
perhaps also constants), but it would allow greater flexibility, putting C++ 
namespace capabilities to some semi-decent use for once:

#1: The long way of typing out things would have you specify a class with, for 
example, fltk3::Group, and global functions like fltk3::Fl::run().

#2: Then, you could shorten it quite a bit:
namespace fl = fltk3;
namespace Fl = fltk3::Fl;

Now the difference in length for global functions would dissapear; it would be 
much the same as without this inner namespace, only global functions (and 
perhaps also constants) would seem, syntactically, much as if they belonged to 
a specific "class" of their own.

#3: Then there is the shortest option, for when you don't need to enclose 
things within the outer namespace:
using namespace fltk3;

Now the Fl:: (which is quite bearable to type) will remain in front of global 
functions (and perhaps also constants), avoiding naming collisions and having 
the nice side-effect of making them instantly recognizable everywhere.


For whatever it might be worth.
_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to