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,55f6e230b02eff2f X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!w3g2000hsg.googlegroups.com!not-for-mail From: Matthew Heaney Newsgroups: comp.lang.ada Subject: Re: Containers - nontrivial element access Date: Thu, 04 Oct 2007 07:01:15 -0700 Organization: http://groups.google.com Message-ID: <1191506475.115935.221440@w3g2000hsg.googlegroups.com> References: <1191275759.184463.238350@n39g2000hsh.googlegroups.com> <1191343071.685478.146710@19g2000hsx.googlegroups.com> <1191358939.031798.177670@k79g2000hse.googlegroups.com> <1191363628.908691.313970@k79g2000hse.googlegroups.com> <1191441598.702440.314410@22g2000hsm.googlegroups.com> <4704e442$0$30370$9b4e6d93@newsspool4.arcor-online.net> NNTP-Posting-Host: 66.162.65.129 Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Trace: posting.google.com 1191506475 16137 127.0.0.1 (4 Oct 2007 14:01:15 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 4 Oct 2007 14:01:15 +0000 (UTC) In-Reply-To: <4704e442$0$30370$9b4e6d93@newsspool4.arcor-online.net> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.7) Gecko/20070914 Firefox/2.0.0.7,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: w3g2000hsg.googlegroups.com; posting-host=66.162.65.129; posting-account=ps2QrAMAAAA6_jCuRt2JEIpn5Otqf_w0 Xref: g2news2.google.com comp.lang.ada:2298 Date: 2007-10-04T07:01:15-07:00 List-Id: On Oct 4, 9:01 am, Georg Bauhaus wrote: > Why not strive for something like > > swap_salary(c1, c2); > where > c1, c2: Cursor; > > As these all are implementation level thoughts, inviting > proper information hiding in place of hinting to mechanisms > in function names (swap), IMHO. Right, and you can generalize that further: generic with package VT is new Vectors (<>); with procedure Process (I, J : VT.Element_Type); procedure Generic_Update_Elements_By_Index (V : in out Vector; I, J : in VT.Index_Type); procedure Generic_Update_Elements_By_Index (V : in out Vector; I, J : in VT.Index_Type) is procedure Process_I (EI : in out ET) is procedure Process_J (EJ : in out ET) is begin Process (EI, EJ); end; begin V.Update_Element (J, Process_J'Access); end; begin V.Update_Element (I, Process_I'Access); end Generic_Update_Elements_By_Index; So now you can say: procedure Swap_Salary (I, J : in out Person) is S : constant Salary_Type := I.Salary; begin I.Salary := J.Salary; J.Salary := S; end; procedure Swap_Salary is new Generic_Update_Elements_By_Index (People_Vectors.Vector_Type, Swap_Salary); V : Vector; Swap_Salary (V, I, J);