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,196864e6c216ca4f X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-28 13:06:25 PST Path: news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread4.news.pas.earthlink.net.POSTED!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.4) Gecko/20030624 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to Emulate C++ Macro with Static Local Variable? References: <17cd177c.0309250354.77444ccd@posting.google.com> <5917f4d0.0309251006.29cd9421@posting.google.com> <3F769EDE.D9D4744F@fakeaddress.nil> In-Reply-To: <3F769EDE.D9D4744F@fakeaddress.nil> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <5bHdb.6832$RW4.2763@newsread4.news.pas.earthlink.net> Date: Sun, 28 Sep 2003 20:06:25 GMT NNTP-Posting-Host: 63.184.8.164 X-Complaints-To: abuse@earthlink.net X-Trace: newsread4.news.pas.earthlink.net 1064779585 63.184.8.164 (Sun, 28 Sep 2003 13:06:25 PDT) NNTP-Posting-Date: Sun, 28 Sep 2003 13:06:25 PDT Xref: news1.google.com comp.lang.ada:87 Date: 2003-09-28T20:06:25+00:00 List-Id: Gautier Write-only wrote: > package BARs is > > type S is array(0..7) of Integer; > > generic > foo: Integer; > package P is > procedure BAR; > end; > > end; > > with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; > > package body BARs is > > package body P is > initialized: Boolean:= False; > cache: S; > procedure BAR is > begin > if not initialized then > cache:= (others=> foo); > New_Line; > Put_Line("[Filling cache for instance]" & Integer'image(foo)); > initialized:= True; > end if; > Put(cache(cache'last)); > end; > end; > > end BARs; There seems to be no need for type S. Why not have generic Foo : Integer; package BARs is procedure BAR; end BARs; with Ada.Text_IO, Ada.Integer_Text_IO; use Ada.Text_IO, Ada.Integer_Text_IO; package body BARs is Cache : Integer := Foo; procedure BAR is begin Put (Cache); end BAR; end BARs; -- Jeff Carter "Oh Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy." Monty Python and the Holy Grail 24