Article View: comp.arch
Article #2104Re: Parity hardware for uninitialized variable checking?
From: Thomas Wang
Date: Mon, 04 Sep 1989 07:07
Date: Mon, 04 Sep 1989 07:07
41 lines
1955 bytes
1955 bytes
barmar@think.COM (Barry Margolin) writes:
>Runtime error detection slows down programs when done only in
>software. That's why language designers would like hardware
>facilities to support it.
One should not need to do software check on uninitialized variables. The
language can be designed so uninitialized variables are impossible
to create.
>Just because a variable is initialized doesn't mean it has a *useful*
>value. C automatically initializes all statics to 0, but that might
>not be a valid value as far as the application is concerned.
You should be able to specify a default initialization value, or even to
explicitly forbid the creation of variables with default value.
>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.
main()
{
type_car my_car; /* create a car with default 4 doors */
}
main()
{
int door_number = get_number_of_doors(stdin);
some_stuff();
type_car my_car(door_number); /* create a car with # doors specified */
}
>Barry Margolin
-Thomas Wang (Ah so desu ka!)
ttwang@polyslo.calpoly.edu
Technical Details
Message-ID:
<14206@polyslo.CalPoly.EDU>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!ames!ncar!unmvax!polyslo!ttwangReferences:
<14166@polyslo.CalPoly.EDU> <28784@news.Think.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!ames!ncar!unmvax!polyslo!ttwang From: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Newsgroups: comp.arch Subject: Re: Parity hardware for uninitialized variable checking? Message-ID: <14206@polyslo.CalPoly.EDU> Date: 4 Sep 89 07:07:38 GMT References: <14166@polyslo.CalPoly.EDU> <28784@news.Think.COM> Reply-To: ttwang@polyslo.CalPoly.EDU (Thomas Wang) Distribution: usa Organization: Cal Poly State University -- San Luis Obispo Lines: 41