From: Sébastien <seb.morand@gmail.com>
Subject: Re: Ada.Containers.Vectors Update_Element issue
Date: Wed, 14 May 2008 15:01:00 +0000
Date: 2008-05-14T15:01:00+00:00 [thread overview]
Message-ID: <482AFEAC.3040306@gmail.com> (raw)
In-Reply-To:
> 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.
next prev parent reply other threads:[~2008-05-14 15:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-13 17:26 Ada.Containers.Vectors Update_Element issue Sébastien
2008-05-13 17:55 ` Adam Beneschan
2008-05-14 15:01 ` Sébastien [this message]
2008-05-14 15:17 ` Adam Beneschan
2008-05-14 18:21 ` Sébastien
2008-05-14 21:25 ` Matthew Heaney
2008-05-14 21:33 ` Adam Beneschan
2008-05-17 8:13 ` Ludovic Brenta
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox