Click here to Skip to main content
15,887,392 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: Sometimes It Pays To Cover All Bases Pin
trønderen2-Mar-24 7:58
trønderen2-Mar-24 7:58 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Gary R. Wheeler2-Mar-24 4:46
Gary R. Wheeler2-Mar-24 4:46 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Rage3-Mar-24 7:50
professionalRage3-Mar-24 7:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Gary R. Wheeler3-Mar-24 9:06
Gary R. Wheeler3-Mar-24 9:06 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen3-Mar-24 10:09
trønderen3-Mar-24 10:09 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Daniel Pfeffer2-Mar-24 6:33
professionalDaniel Pfeffer2-Mar-24 6:33 
JokeRe: Sometimes It Pays To Cover All Bases Pin
Nelek2-Mar-24 7:35
protectorNelek2-Mar-24 7:35 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen2-Mar-24 8:30
trønderen2-Mar-24 8:30 
The problem is rooted in
Daniel Pfeffer wrote:
the underlying variable is an int (or another integral type)
If enumeration was a first class type, "++weekday;" (given Daniel Pfeffer's enum definition) would generate a runtime error, similar to a numeric overflow exception. Unless, of course if the enumeration type allows an enum to be defined as cyclical, in which case the new value would be SUNDAY.
Nelek wrote:
That doesn't generate error here... we start the week on Monday
First: I think that goes for all of Western Europe nowadays. We (Norway) changed from Sunday to Monday as the first day of the week something like 40-50 years ago to be in harmony with other European countries.

As the English term is 'weekend', and Sunday is part of the weekend, I always assumed that Sunday ended the week in English speaking countries. I was surprised to learn that while this is true in GB, in the US of A it appears that the week ends one day before the weekend ends.

A little nitpicking: Different cultures disagree about the first day of the week. If you make software for use in multiple cultures, you cannot (or at least should not) replace the enum definition when you start marketing the software in a new region; that could result in subtle errors. Rather, the enum definition should be completely ignorant of which value is considered to be the position of the air valve on the rotating wheel.

So, Daniel Pfeffer's definition is perfectly OK, even in Europe, assuming that his application code never makes any assumption about the first enum value being the first day of the week. Given that enum is not a first class type, the code would correctly go to the default case even in Europe.

If your language allows: Overload ++ for the weekday type, to make weekday++ == SUNDAY when the old value of weekday == SATURDAY. Then it doesn't matter.

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: Sometimes It Pays To Cover All Bases Pin
Nelek3-Mar-24 0:50
protectorNelek3-Mar-24 0:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
trønderen3-Mar-24 1:50
trønderen3-Mar-24 1:50 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
mdblack984-Mar-24 2:12
mdblack984-Mar-24 2:12 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Derek Hunter4-Mar-24 2:38
Derek Hunter4-Mar-24 2:38 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
glennPattonWork34-Mar-24 8:49
professionalglennPattonWork34-Mar-24 8:49 
GeneralRe: Sometimes It Pays To Cover All Bases Pin
Steve Naidamast4-Mar-24 4:04
professionalSteve Naidamast4-Mar-24 4:04 
GeneralWhen is a backup not a backup? PinPopular
theoldfool29-Feb-24 23:43
professionaltheoldfool29-Feb-24 23:43 
GeneralRe: When is a backup not a backup? Pin
Ron Anders1-Mar-24 1:54
Ron Anders1-Mar-24 1:54 
GeneralRe: When is a backup not a backup? Pin
theoldfool1-Mar-24 3:33
professionaltheoldfool1-Mar-24 3:33 
GeneralRe: When is a backup not a backup? Pin
DerekT-P1-Mar-24 2:04
professionalDerekT-P1-Mar-24 2:04 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 4:04
dandy721-Mar-24 4:04 
GeneralRe: When is a backup not a backup? Pin
theoldfool1-Mar-24 7:49
professionaltheoldfool1-Mar-24 7:49 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 7:54
dandy721-Mar-24 7:54 
GeneralRe: When is a backup not a backup? Pin
Nelek1-Mar-24 9:01
protectorNelek1-Mar-24 9:01 
GeneralRe: When is a backup not a backup? Pin
dandy721-Mar-24 10:10
dandy721-Mar-24 10:10 
GeneralRe: When is a backup not a backup? Pin
Nelek1-Mar-24 11:39
protectorNelek1-Mar-24 11:39 
GeneralRe: When is a backup not a backup? Pin
charlieg1-Mar-24 23:01
charlieg1-Mar-24 23:01 

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.