From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ec21c3c7cdc7ff3e X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Message-ID: <441C13DB.91C219FE@fakeaddress.nil> Date: Sat, 18 Mar 2006 15:06:19 +0100 From: Gautier X-Mailer: Mozilla 4.8 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Uninitialized variables (was: Re: private types) References: <1142279908.327131.230200@j52g2000cwj.googlegroups.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 81.62.3.38 X-Original-NNTP-Posting-Host: 81.62.3.38 X-Trace: news.bluewin.ch 1142690803 81.62.3.38 (18 Mar 2006 15:06:43 +0100) Organization: Bluewin AG Complaints-To: abuse@bluewin.ch X-Original-NNTP-Posting-Host: 127.0.0.1 Path: g2news1.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!wn11feed!worldnet.att.net!164.128.36.58!news.ip-plus.net!newsfeed.ip-plus.net!news.bluewin.ch!not-for-mail Xref: g2news1.google.com comp.lang.ada:3432 Date: 2006-03-18T15:06:19+01:00 List-Id: Here (trying to to sum up), 3 problems I see with the tactic of initializing everything: - useless initializations (i.e. dummy values rewritten later) take time and usually _hurt_ performance (think to number crunching with huge objects, or frequently used functions with local variables) - useless initializations introduce meaningless code lines - [Dirk] useless initializations prevent detecting bugs that can be detected without these initializations (they can be detected by combining the Initialize_Scalars pragma and the validity checks) My rule is rather to initialize _only_ variables you can give a meaningful values. Of course it depends on the context. Maybe there are situations where you can prefer a program giving wrong results than an unhandled exception popping at the wrong moment (although I find the method very shocking!)... In such cases the systematic initialization could be a way (not nice but pragmatic) to silently disable bug detection. _______________________________________________________________ Gautier -- http://www.mysunrise.ch/users/gdm/index.htm Ada programming -- http://www.mysunrise.ch/users/gdm/gsoft.htm NB: For a direct answer, e-mail address on the Web site!