| [ Return to Bugs & Features | Roadmap 1.3 | SVN ⇄ GIT ]
STR #3258
Application: | FLTK Library |
Status: | 2 - Closed w/o Resolution |
Priority: | 1 - Request for Enhancement, e.g. asking for a feature |
Scope: | 3 - Applies to all machines and operating systems |
Subsystem: | Core Library |
Summary: | Why not using c++ style of enumeration constants? |
Version: | 1.3-feature |
Created By: | sabmab |
Assigned To: | AlbrechtS |
Fix Version: | None |
Update Notification: | |
Trouble Report Files:
No files
Trouble Report Comments:
|
#1 | sabmab 03:45 Sep 15, 2015 |
| Hello I am an amateur programmer. I have good experience with c++. but I am new to GUI programming. So forgive me if my suggestion seems stupid or have bad side that I cannot see.
Since FLTK is c++ library why the enumeration is in c style?
I am suggesting to do the following inside Enumerations.H
namespace FLTK { namespace Versions { void Version(){} enum {MAJOR=FL_MAJOR_VERSION, MINOR=FL_MINOR_VERSION, PATCH=FL_PATCH_VERSION, VERSION}; enum {ME, YOU}; }
namespace Events { enum{NO_EVENT =FL_NO_EVENT , PUSH =FL_PUSH } } of course the previous code is a sample which can be generalized for other enumerations.
In general this approach will give us four benefits 1- Allows us to get the syntactic sugar of c++ with out breaking any thing. Instead of using FL_MAJOR_VERSION we can use FLTK::Version::MAJOR or some thing similar. 2- The auto completion will help you to remember all enumeration without going back and forth to documentation. 3- Help the library to follow the c++ way of programming 4- Make the learning curve for newbies (like me) smoother and easier.
If you like the idea I will volunteer and do it but I need a guidance from an experienced FLTK user. regards Saleh | |
|
#2 | engelsman 00:15 Sep 17, 2015 |
| This is something that you should really raise over on fltk.coredev because few people are actively following fltk.bugs beyond getting notifications about those problems that they themselves have reported.
The main reason that FLTK uses C macros rather than C++ enums is that, historically at least, not all of the compilers available on embedded systems were as up-to-date as they could be in supporting all features. Hence FLTK code was limited to using the lowest common denominator of features. Whether (a) anyone is still using these embedded systems, and (b) their compilers are still so antiquated, is another question.
The C++ Portability section of the FLTK Configuration Management Plan available at http://www.fltk.org/cmp.php#CODING_STANDARDS:
"Since FLTK is targeted at platforms which often lack complete ISO C++ support or have limited memory, all C++ code in FLTK must use a subset of ISO C++. FLTK These restrictions shall be reviewed prior to each major release of FLTK."
FLTK-1 code cannot use: Exceptions, Namespaces, Standard C++ headers, Templates, and dynamic_cast and family.
It's worth discussion on fltk.coredev but I can't see any changes in the near future, certainly not before 1.3.4 is released, and not until there's been a survey/discussion about which embedded systems are still being used, and what their compilers support.
Maybe this is something that could be presented as a home page poll:
Which of the following areas are not supported by your compiler? a. Exceptions b. Namespaces c. Standard C++ headers and library d. Templates e. dynamic_cast and family | |
|
#3 | sabmab 03:14 Sep 18, 2015 |
| First thanks for replying and clarifying the reason why enumeration is not used.
I think the home page poll is a good Idea.
On fltk.coredev, I will discuss what the harm if namespaces are used only of enumeration, for now. In the future, when the results of the poll come out, they can decide whether to use it for other parts or not. | |
|
#5 | AlbrechtS 11:23 Feb 01, 2019 |
| Using namespaces in FLTK 1.x.y is not going to be done (allowed) anytime soon. If you're still interested in this topic, please discuss (maybe again?) in fltk.coredev.
Closing this STR now. | |
[ Return to Bugs & Features ]
|
| |