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 Path: g2news1.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newscon06.news.prodigy.com!prodigy.net!newsfeed-00.mathworks.com!kanaga.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!cern.ch!news From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: private types Date: Fri, 17 Mar 2006 08:40:32 +0100 Organization: CERN - European Laboratory for Particle Physics Message-ID: References: <1142279908.327131.230200@j52g2000cwj.googlegroups.com> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sunnews.cern.ch 1142581232 28949 (None) 137.138.37.241 X-Complaints-To: news@sunnews.cern.ch User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060203 Red Hat/1.7.12-1.1.3.4 X-Accept-Language: en-us, en In-Reply-To: Xref: g2news1.google.com comp.lang.ada:3395 Date: 2006-03-17T08:40:32+01:00 List-Id: Justin Gombos wrote: >>He does have a point though - some languages will initialise all >>variables to dummy values - this means you can get predictable >>results in code that (wrongly) uses them before setting them to a >>value. > > Beyond access types, I would not consider that feature you're > describing helpful. In fact, it's more of a disservice. So you have the whole pragma as such "disservice": http://www.adaic.org/standards/95aarm/html/AA-H-1.html > The first problem: initializing to zero, or some other "dummy" value > of the compilers choice is likely to result in a valid value > (sometimes), which only serves to /hide/ bugs in the cases where the > object is used prior to a meaningful assignment. Right. Then, why not minimize the scope of the object to the extent when it's never even visible before being initialized with the value that is meaningful in the given context? It's not always possible, of course, but in many (most?) cases programmers tend to put all variables at the beginning of some rather coarse-grained scope (for example, beginning of the procedure or function), and later wonder what is the "right" initial value for them. It's the misplacement of declaration that is a primary source of problems and this is what should be actually addressed. > Then problem with user forced initialization (which is what the OP is > after): it could mask the cases where reassignment is inevitable. > IOW, suppose you have subprograms like this: > > function exists return boolean is > > --Later assignment to found_it is evitable > -- > found_it : boolean := false; > > begin > > if some_precondition then > > found_it := some_other_condition; > > end if; > > return found_it; > > end exists; Single entry - single exit syndrome? :) -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/