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,a3736685ef876ab2 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!b15g2000hsa.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: OO Style with Ada Containers Date: Tue, 27 Nov 2007 12:12:35 -0800 (PST) Organization: http://groups.google.com Message-ID: References: <1195082906.420079.195000@d55g2000hsg.googlegroups.com> <1195084214.480299.13970@t8g2000prg.googlegroups.com> <1195084752.840598.174460@v65g2000hsc.googlegroups.com> <1195086265.070953.93180@d55g2000hsg.googlegroups.com> <2e37536e-55fb-42d5-a073-10b47cc31128@v4g2000hsf.googlegroups.com> <50024075-f96e-4501-bca2-fef642b799a7@j44g2000hsj.googlegroups.com> <1196191906.24671.119.camel@kartoffel> NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1196194355 6378 127.0.0.1 (27 Nov 2007 20:12:35 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 27 Nov 2007 20:12:35 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: b15g2000hsa.googlegroups.com; posting-host=66.162.65.129; posting-account=umyUbgkAAADe5rQC4VzV-ffCoH4N30u3 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.10) Gecko/20071115 Firefox/2.0.0.10,gzip(gfe),gzip(gfe) Content-Disposition: inline Xref: g2news1.google.com comp.lang.ada:18651 Date: 2007-11-27T12:12:35-08:00 List-Id: On Nov 27, 2:31 pm, Georg Bauhaus wrote: > On Mon, 2007-11-26 at 12:29 -0800, Matthew Heaney wrote: > > generic > > with procedure Process (Word : String); > > procedure Generic_Scan (File : File_Type); > > Hm. Isn't a local variable together with a local function > modifying the local variable a viable option? Yes, that local function would be the generic actual in my example. > There is no > 'Access then, but only "access" in a logical sense. The > variable/constant is not passed to the function but still > visible and accessible to the function. Yes, of course. > One could even wrap > them both in the same local package. The package might not > establish coupling in a type, but nevertheless it establishes > coupling of things that belong together. I'm not sure I was clear here. I meant: package Scanner is generic with procedure Process (Word : String); procedure Generic_Scan (File : File_Type); end Scanner; Actually, in Ada05 you don't need the generic at all: package Scanner is procedure Scan (File : File_Type, Process : not null access Process (Word : String)); end Scanner; Then you could say: declare M : Map; procedure Insert_Word (Word : String) is procedure Inc (Count : in out Natural) is begin Count := Count + 1; end; C : Cursor; B : Boolean; begin M.Insert (Word, 0, C, B); M.Update_Element (C, Inc'Access); end; F : File_Type; begin Open (F, ...); Scanner.Scan (F, Insert_Word'Access); ... -- do something with map end;