Click here to Skip to main content
14,367,789 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
decaffeinatedMonkey12-Sep-19 4:18
memberdecaffeinatedMonkey12-Sep-19 4:18 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
agolddog12-Sep-19 4:29
memberagolddog12-Sep-19 4:29 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Rick York12-Sep-19 5:50
mveRick York12-Sep-19 5:50 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
AnotherKen12-Sep-19 5:19
professionalAnotherKen12-Sep-19 5:19 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 5:20
memberhoney the codewitch12-Sep-19 5:20 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 5:20
memberMember 798912212-Sep-19 5:20 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 5:23
memberhoney the codewitch12-Sep-19 5:23 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 7:15
memberMember 798912212-Sep-19 7:15 
honey the codewitch wrote:
Although hate enums, because .NET made them slow. I still use them, but they make me frustrated.
The very first compiler I dug into was the Pascal P4 compiler - those who think "open source" is something that came with Linux are completely wrong. Pascal provides enums as first class types, not something derived from integer.

The compiler source showed very clearly how the compiler treats enums just like integers; it just doesn't mix the two types up, it doensn't allow you to use them interchangably. It is like having intTypeA and intTypeB which are 100% incompatible. If you do casting to (or from) int, it is a pure compile-time thing: It shortcuts the error handling reporting that the types are incompatible. There is nothing that causes more instructions to be executed when you use enums rather than int - not even when you do casting. Why would there be? Why should .net make them slower?

If you have full enum implementation (like that of Pascal) and make more use of it, then there may of course be a few more instructions generated. E.g. if you have a 12-value enum from janurary to december, and define an array with indexes from april to august, then the runtime code must skew the actual index values so that an "april" index is mapped to the base adress of the array, not three elements higher. Index values must be checked against the array declaration: january to march and september to december must generate an exception. But that is extended functionality - if you want that with integer indexes, and the same checking, you would generate a lot more code writing the index scewing and testing as explicit C statements.

Maybe the current C# .net compiler is not doing things "properly" - similar to that Pascal compiler written in the early 1970s. I guess it could. I see no reason why it should be able to, nothing in semantics of C# "semi-enums" making it more difficult that Pascal's full enum implemnentation.
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 8:17
memberhoney the codewitch12-Sep-19 8:17 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 10:37
memberMember 798912212-Sep-19 10:37 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 11:58
memberhoney the codewitch12-Sep-19 11:58 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 14:37
memberMember 798912212-Sep-19 14:37 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 14:40
memberhoney the codewitch12-Sep-19 14:40 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Alister Morton12-Sep-19 5:42
memberAlister Morton12-Sep-19 5:42 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 5:47
memberTrinityRaven12-Sep-19 5:47 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 5:52
memberhoney the codewitch12-Sep-19 5:52 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 6:23
memberTrinityRaven12-Sep-19 6:23 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
honey the codewitch12-Sep-19 6:54
memberhoney the codewitch12-Sep-19 6:54 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 7:50
memberMember 798912212-Sep-19 7:50 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
TrinityRaven12-Sep-19 8:46
memberTrinityRaven12-Sep-19 8:46 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 11:13
memberMember 798912212-Sep-19 11:13 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Bruce Greene12-Sep-19 5:51
memberBruce Greene12-Sep-19 5:51 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Ira Greenstein12-Sep-19 6:07
memberIra Greenstein12-Sep-19 6:07 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Member 798912212-Sep-19 7:52
memberMember 798912212-Sep-19 7:52 
GeneralRe: do any of you others have little coding mantras that save your behind? Pin
Ira Greenstein12-Sep-19 9:11
memberIra Greenstein12-Sep-19 9:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.