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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5bbcbfbb228d6549 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!club-internet.fr!feedme-small.clubint.net!news.motzarella.org!motzarella.org!not-for-mail From: =?ISO-8859-1?Q?S=E9bastien?= Newsgroups: comp.lang.ada Subject: Re: Ada.Containers.Vectors Update_Element issue Date: Wed, 14 May 2008 15:01:00 +0000 Organization: A noiseless patient Spider Message-ID: <482AFEAC.3040306@gmail.com> References: <4bb8bb12-225b-4790-bd12-40ef0b0adeaf@s33g2000pri.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: feeder.motzarella.org U2FsdGVkX19yKyXe9ty/iTHoQub2UElntV12gwzI3cE0As3YJjHNOvL/HbHS5OB/ND4KyP2u2pgvkbvUsRYAYHQm9JvDOTNYJr2O3qQHVTrqLlTO/TbOYQMlYRnDNU8V25bM7wxtdgO90wImwJVJdQ== X-Complaints-To: Please send complaints to abuse@motzarella.org with full headers NNTP-Posting-Date: Wed, 14 May 2008 15:00:53 +0000 (UTC) In-Reply-To: X-Auth-Sender: U2FsdGVkX18cDUjkSMPJz5qDWJWgGqHWnX6X8UOjXyEKzXk2I1yg4A== Cancel-Lock: sha1:QMIJDvjvepXBESIwP4MTX1IdK24= User-Agent: Thunderbird 2.0.0.14 (Windows/20080421) Xref: g2news1.google.com comp.lang.ada:59 Date: 2008-05-14T15:01:00+00:00 List-Id: > procedure Update_All (c : in out context) is > procedure Do_The_Update (Element : in out Element_Type) is > begin > My_Update (c, Element); > end Do_Update; > begin > my_list.Update_Element (1, Do_The_Update'Access); > end Update_All; > > I haven't tried this. However, it should work because the Process > parameter to Update_Element is declared as an anonymous access- > procedure type, rather than as a named access-procedure type, and this > means you can pass a nested procedure access to it without any > accessibility-level issues. (This sort of usage is exactly why > anonymous access-subprograms types were added to Ada 2005.) Ok I didn't think about nested proc having access to argument. When you mean anonymous access, you are meaning "Do_The_Update'Access"? There was no procedure access in previous ada version? Anyway it's working fine. >> generic >> c: Context; >> procedure My_Update_Generic(Element: in out Element_Type); >> >> procedure Update_All(c: in out context) is >> procedure My_Update is new My_Update_Generic(c => c); >> begin >> my_list.Update_Element(1, My_Update'Access); >> end; >> >> That's not working and I can understand it ;-) No dynamical address >> since the generic will instancied at runtime or something like that ... > > Offhand, I *don't* understand why this wouldn't work. It seems like > it should. Is the compiler giving you an error message, or are you > getting exceptions or bad behavior at runtime? > > But you shouldn't need a generic; the nested procedure solution should > work fine. The compiler said it's a bug... However I'm not able to do it again, it works fine now but I prefer the method above.