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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9768c08202fdbbb1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-11-12 07:39:40 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!postnews1.google.com!not-for-mail From: dennison@telepath.com (Ted Dennison) Newsgroups: comp.lang.ada Subject: Re: Let's change semantics of "use type" Date: 12 Nov 2002 07:39:40 -0800 Organization: http://groups.google.com/ Message-ID: <4519e058.0211120739.4f744784@posting.google.com> References: <3dcb8347$0$299$bed64819@news.gradwell.net> <4519e058.0211110759.3ebbf128@posting.google.com> NNTP-Posting-Host: 65.115.221.98 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1037115580 5324 127.0.0.1 (12 Nov 2002 15:39:40 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 12 Nov 2002 15:39:40 GMT Xref: archiver1.google.com comp.lang.ada:30761 Date: 2002-11-12T15:39:40+00:00 List-Id: "R. Tim Coslet" wrote in message news:... > The only real use I have ever found in Ada95 for rename is when I need to > make repeated references to the same array element in several places in a > block of code. I rename the array element (to tell the compiler to index it > only once) then use the new name in the places in the code that reference > it. > > Example: > > declare > Selected_Item : Some_Typ renames Big_Arrayo_of_Data(x,y,z); > begin > if Selected_Item = Special_Value then > y := Complex_Function(Selected_Item,z); > ... more code refering to Selected_Item ... > end if; > Selected_Item := Fancy_Function(x,i); > end; Were it me, I'd replace this entire declare block with a routine. In fact, were I to come across this in code I was reading, I'd certianly refactor it as such. The interfaces into and out of a routine are much narrower and better defined, so they are far better from a maintanence (and code understanding) standpoint. In fact, its quite rare that I *ever* use a declare block for anything other than localizing exception handling.