foxblock / penjin

Penjin game engine - C++, cross-platform, powerful, simple to use
http://projectinfinity.org.uk/doku.php?id=homebrew:engines:penjin
GNU Lesser General Public License v3.0
0 stars 1 forks source link

About definition conflicts with enums #9

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Lately I ran into some definition conflicts with enums (multiple use of the
same identifier). 
These can be quite annoying and certain strings such as "CUSTOM" are
commonly used, so they can easily lead to such conflicts.

Proposed solution: Add a prefix to any identifier which describes what
category it belongs to (for example the first two letters of enum's name).
This is how it's done in Delphi and it works quite well, also if the prefix
is chosen wisely it can be easily guessed by the user and does not lead to
additional confusion, but might also show the purpose of the used
identifier (as one can guess from the prefix which class/category it
belongs to).

Some examples would be:
enum PENJIN_COLOURS
{
  pcBLACK,
  pcWHITE,
  pcRED,
...
}

enum TimerScalers
{
  tsMILLI_SECONDS,
  tsSECONDS,
...
}

The only problem I see is that this change would require some Find and
Replace work on most of the code, which can be time consuming, so it's
mostly an enhancement request for when there are some lonely hours.

Original issue reported on code.google.com by foxbl...@gmail.com on 10 Dec 2009 at 6:38

GoogleCodeExporter commented 9 years ago
meh, fixed typo in title

Original comment by foxbl...@gmail.com on 10 Dec 2009 at 6:39

GoogleCodeExporter commented 9 years ago
or wrap into a namespace.

Original comment by pokeparadox@gmail.com on 10 Dec 2009 at 7:23

GoogleCodeExporter commented 9 years ago
And for what reason did I write that lengthy text then?

I still like my idea more...

Original comment by foxbl...@gmail.com on 10 Dec 2009 at 7:41

GoogleCodeExporter commented 9 years ago
Meh... ok I've thought about it and you win... although you do get a trout slap 
for
suggesting that I sit and find a replace code. :P

Original comment by pokeparadox@gmail.com on 21 Jan 2010 at 1:55

GoogleCodeExporter commented 9 years ago
I always win eventually
But nice you felt spoken to because I mentioned "for lonely hours" :P

Original comment by foxbl...@gmail.com on 21 Jan 2010 at 5:13