Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Ada > Re: Ada.Contain...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 5697 of 5831
Post > Topic >>

Re: Ada.Containers.Vectors Update_Element issue

by Adam Beneschan <adam@[EMAIL PROTECTED] > May 13, 2008 at 10:55 AM

On May 13, 10:26 am, S=E9bastien <seb.mor...@[EMAIL PROTECTED]
> wrote:
> Hi,
>
> I'm trying to use the Ada.Containers.Vectors librairies, but I don't
> know how to update element using a context.
>
> I have a list of element and I want to use Update_Element with a
> procecedure Update_Element_Process, however I want to add static
> argument to the Update_Element_Process.
>
> This could be something like :
>
> procedure My_Update(c: in out context; Element: in out Element_Type);
>
> and then
>
> procedure Update_All(c: in out context) is
> begin
>         my_list.Update_Element(1, My_Update'Access);
> end;
>
> Because My_Update is not exacly the type Update_Element_Process it's nor
> working.

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.)


> type Update_Element_Process is
>     access procedure (Element : in out Element_Type);
>
> Note that generic doesn't help : they give me a bug error compilation
> because of Address invalid of the generic instance.
>
> I tried this:
> 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 =3D> 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.

                              -- Adam
 




 8 Posts in Topic:
Ada.Containers.Vectors Update_Element issue
=?ISO-8859-1?Q?S=E9bastie  2008-05-13 17:26:40 
Re: Ada.Containers.Vectors Update_Element issue
Adam Beneschan <adam@[  2008-05-13 10:55:21 
Re: Ada.Containers.Vectors Update_Element issue
=?ISO-8859-1?Q?S=E9bastie  2008-05-14 15:01:00 
Re: Ada.Containers.Vectors Update_Element issue
Adam Beneschan <adam@[  2008-05-14 08:17:36 
Re: Ada.Containers.Vectors Update_Element issue
=?ISO-8859-1?Q?S=E9bastie  2008-05-14 18:21:30 
Re: Ada.Containers.Vectors Update_Element issue
Matthew Heaney <mheane  2008-05-14 14:25:21 
Re: Ada.Containers.Vectors Update_Element issue
Adam Beneschan <adam@[  2008-05-14 14:33:50 
Re: Ada.Containers.Vectors Update_Element issue
Ludovic Brenta <ludovi  2008-05-17 10:13:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 20:44:37 CDT 2008.