Click here to Skip to main content
15,884,298 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.

 
JokeRe: Oh boy. I've given myself a challenge now. Pin
Memtha16-Feb-22 15:45
Memtha16-Feb-22 15:45 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Mycroft Holmes16-Feb-22 11:36
professionalMycroft Holmes16-Feb-22 11:36 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
FreedMalloc16-Feb-22 14:26
FreedMalloc16-Feb-22 14:26 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
englebart16-Feb-22 14:52
professionalenglebart16-Feb-22 14:52 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha16-Feb-22 15:52
Memtha16-Feb-22 15:52 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
David O'Neil16-Feb-22 22:14
professionalDavid O'Neil16-Feb-22 22:14 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha17-Feb-22 5:23
Memtha17-Feb-22 5:23 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
trønderen17-Feb-22 6:40
trønderen17-Feb-22 6:40 
C# variables have initial values of binary zero, by language definition. I don't think C is similar, but correct me if I am wrong. I believe that there are other languages that defines initial values of zero.

This has been debated for years, and apparently someone in the VS team disagree with the C# designers: I get a curly warning line if I use an unassigned variable. Maybe I could switch that off, but I think it is OK the way it is.

I learned my first "serious" programming in Pascal, where a type may define a value range that does not include a zero value (such as an integer ranging from 1900 .. 2100). It would be rather meaningless for the language to specify an illegal initial value for some variables, arguing that it makes sense for other variables. In Pascal, enumerations are not named integers: If you define one TYPE Color = (red, blue, green, yellow); you should not take for granted that red is represented as binary zero. Even though Pascal treats the values as ordered, the application semantics often doesn't (for colors, the rainbow ordering is often completely irrelevant). If, for some reason, the order in the type definition is changed, with internal values assigned from 0 and initial values binary zero, this could cause a change in program semantics even if the code does not consider colors ordered.

If you insist on some defined initial value, a much better value would be upper bit set, remaining bits zero. In most architectures, a 0x1000...000 pointer is likely to point outside the heap, to be caught as uninitialized. An integer would be -MAXINT-1, an abnormal value which is its own negation. For sign/exp/mantissa float, it is minus zero. For enums, it it practically always outside limits. Character code 1000 0000 is not assigned any function. It is quite likely than an unassigned value would be caught - far more so than with all zero initial value
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Memtha17-Feb-22 6:53
Memtha17-Feb-22 6:53 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
David O'Neil16-Feb-22 22:22
professionalDavid O'Neil16-Feb-22 22:22 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
Richard Deeming17-Feb-22 2:08
mveRichard Deeming17-Feb-22 2:08 
GeneralRe: Oh boy. I've given myself a challenge now. Pin
FreedMalloc17-Feb-22 5:25
FreedMalloc17-Feb-22 5:25 
GeneralCCC 2022-02-16 Pin
Peter_in_278015-Feb-22 22:03
professionalPeter_in_278015-Feb-22 22:03 
GeneralRe: CCC 2022-02-16 Pin
OriginalGriff15-Feb-22 22:05
mveOriginalGriff15-Feb-22 22:05 
GeneralRe: CCC 2022-02-16 Pin
pkfox15-Feb-22 23:19
professionalpkfox15-Feb-22 23:19 
GeneralRe: CCC 2022-02-16 Pin
OriginalGriff15-Feb-22 23:25
mveOriginalGriff15-Feb-22 23:25 
GeneralRe: CCC 2022-02-16 Pin
pkfox16-Feb-22 3:38
professionalpkfox16-Feb-22 3:38 
GeneralRe: CCC 2022-02-16 Pin
Greg Utas16-Feb-22 1:00
professionalGreg Utas16-Feb-22 1:00 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:09
professionalPeter_in_278016-Feb-22 1:09 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Greg Utas16-Feb-22 1:13
professionalGreg Utas16-Feb-22 1:13 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:20
professionalPeter_in_278016-Feb-22 1:20 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
OriginalGriff16-Feb-22 1:31
mveOriginalGriff16-Feb-22 1:31 
GeneralRe: CCC 2022-02-16 - WINNER! Pin
Peter_in_278016-Feb-22 1:31
professionalPeter_in_278016-Feb-22 1:31 
RantI'd have rather paid extra Pin
honey the codewitch15-Feb-22 19:08
mvahoney the codewitch15-Feb-22 19:08 
GeneralRe: I'd have rather paid extra Pin
Sander Rossel15-Feb-22 19:55
professionalSander Rossel15-Feb-22 19:55 

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.