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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,cef1968b544ddf26 X-Google-Attributes: gid103376,public From: Samuel Tardieu Subject: Re: Static variables? Date: 1997/03/18 Message-ID: #1/1 X-Deja-AN: 226378149 Sender: tardieu@esmeralda.enst.fr References: <332D71FF.4773@cae.ca> Organization: TELECOM Paris Newsgroups: comp.lang.ada Date: 1997-03-18T00:00:00+00:00 List-Id: >>>>> "Jon" == Jon S Anthony writes: Jon> In article <332D71FF.4773@cae.ca> Viqar Abbasi Jon> writes: >> Is there a way to declare local variables in ADA subprograms to be >> STATIC? That is, they retain the value that they had when the >> subprogram was last exited. Jon> Just put the variable at the same or lower scope than the Jon> subprogram that is to use it. Typically this is at package Jon> level. This is of course the way to do it, but your answer corresponds to the case of a C toplevel static variable, not to the case of a C static variable located in a function. In the first case, your variable may be accessed by several subprograms, in the second one, it can only be accessed by *one* C function. This is not possible in Ada to have the equivalent of a C static variable located in a function, you have to put it at the module (package) level, let's say in the package body as Jon said. Sam -- Samuel Tardieu -- sam@ada.eu.org