Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!think!barmar From: barmar@think.COM (Barry Margolin) Newsgroups: comp.arch Subject: Re: Parity hardware for uninitialized variable checking? Message-ID: <28866@news.Think.COM> Date: 5 Sep 89 22:32:25 GMT References: <14166@polyslo.CalPoly.EDU> <28784@news.Think.COM> <14206@polyslo.CalPoly.EDU> Sender: news@Think.COM Reply-To: barmar@kulla.UUCP (Barry Margolin) Distribution: usa Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 24 In article <14206@polyslo.CalPoly.EDU> ttwang@polyslo.CalPoly.EDU (Thomas Wang) writes: >barmar@think.COM (Barry Margolin) writes: >>In article <14166@polyslo.CalPoly.EDU> ttwang@polyslo.CalPoly.EDU (Thomas Wang) writes: >>>Yes. Insist you initialize a variable when you create it. >>What if you don't know what value it should have yet? >You can create the variable with a default value, or delay the creation of >the variable until you know what value it should have. My contention is that a variable with a default value is often just as bad as an uninitialized variable. Sure, it has a well-defined value, but it's not the value you really care about, and it might not make sense to use the variable until it gets a more meaningful value. Consider a language that automatically initializes all pointer variables to NULL when they are created. Strictly speaking, there are no uninitialized pointer variables in such a language. However, it's still not valid to dereference a pointer until you REALLY initialize it to point to something. Barry Margolin Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar