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,5af5c381381ac5a7 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!goblin3!goblin.stu.neva.ru!bolzen.all.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Ada requires too much typing! Date: Tue, 08 Jun 2010 13:10:38 +0300 Organization: Tidorum Ltd Message-ID: <876j8vF54kU1@mid.individual.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net LteIy9TZXi05iRq3wcKJDwp44Du7ujiohjFy1ISJWwsP0Q3/RP Cancel-Lock: sha1:Z1bQ9xsqWgLITxsd+4E063E6sMo= User-Agent: Mozilla-Thunderbird 2.0.0.24 (X11/20100328) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:12440 Date: 2010-06-08T13:10:38+03:00 List-Id: Martin Krischik wrote: > just about as painful as using local packages to add static variables to > Ada procedures. Later Martin Krischik wrote: > function f returns Integer > > package i is > g : Integer := 0; > end i; > > begin > i.g := i.g + 1; > return i.g; > end f; If you mean the latter code to be an example of the former task (add static variable), I believe you are mistaken. The variable f.i.g is not "static" in the sense of being statically allocated. The nested package i is elaborated on each invocation of function f, which means that f.i.g is stack allocated, initialized to 0 on each invocation of f, then incremented to 1. Thus f always returns 1. To make a statically allocated variable, you need a library package. Perhaps you are thinking of the technique suggested by Mark Lundquist, at http://www.adapower.com/index.php?Command=Class&ClassID=Basics&CID=204 That technique uses a nested package inside a library package, but not within the subprogram using the variable. The nesting is used only to hide the variable from other subprograms that are in the same library package but are not in the nested package. -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .