From: di98mase@hotmail.com (Sebastian)
Subject: Re: Pointers in Ada
Date: 5 Mar 2005 07:47:41 -0800
Date: 2005-03-05T07:47:41-08:00 [thread overview]
Message-ID: <6acda821.0503050747.79f9544f@posting.google.com> (raw)
In-Reply-To: 0L1Wd.824$oO4.709@newsread3.news.pas.earthlink.net
Jeffrey Carter <spam@spam.com> wrote in message news:<0L1Wd.824$oO4.709@newsread3.news.pas.earthlink.net>...
> Sebastian wrote:
>
> > package Mdp_Lld;
> > type Message_Header is
> > record
> > Word_Count : Byte;
> > Command_Id : Byte;
> > end record;
> >
> > subtype Mdp_Message_Data is Byte(1..500);
> >
> > type A_Mdp_Message is
> > record
> > Header : aliased Message_Header;
> > Data : aliased Mdp_Message_Data;
> > end record;
> >
> > type Driver_Msg_Ptr_Type is access all A_MDP_Message;
> >
> > procedure Put_Message
> > (Msg_Buffer_Ptr : in out Client_Msg_Ptr_Type;
> > );
>
> As you're no doubt aware, this won't compile. In addition to the syntax
> error in the declaration of Put_Message, Client_Msg_Ptr_Type has not
> been declared.
>
> Before we can answer your questions, we need to know why you're using
> pointers. What wrong with
>
> procedure Put_Message (Message : in An_Mdp_Message);
>
> ?
>
> In Ada pointers are needed far more rarely than in some other languages.
> Since you're not building a dynamic data structure, it's likely that you
> don't need them. If you really do need them, it's probably a better
> design to hide them from the clients of the package. That way you can
> localize the memory management to your package.
Hi everybody
thanks for your answers. First, I have not written the code myself it
is a UDP/IP stack that I found as a open source. I would not use
pointers myself thats why I'm havning problems knowing how to
initialize them;) Anyway, sorry that the code does not compile but I
extracted it from the files and "tweaked" it to fit the forum.
Soo, in order to create a message and send it using Put_Message I have
to create a variable of the private type Client_Msg_Ptr_Type in "my
calling source code file" BUT in order to do that the calling code
must be within a child package to the Mdp_lld package otherwise the
private type is not visable, or am I missing something here? Also the
Outmessage has to be aliased and I have to write the code like:
My_Msg_Ptr := Outmessage'Access;
Will this work? Well I will try it on monday...I'll let you know..
Thanks,
Sebastian
next prev parent reply other threads:[~2005-03-05 15:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-04 12:25 Pointers in Ada Sebastian
2005-03-04 13:03 ` Adrien Plisson
2005-03-04 18:26 ` Jeffrey Carter
2005-03-05 15:47 ` Sebastian [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-11-14 18:16 pointers " lalasa ala
2001-11-14 18:46 ` Matthew Heaney
2001-11-14 19:04 ` Preben Randhol
2001-11-14 20:10 ` Stephen Leake
2001-11-15 7:32 ` Preben Randhol
2001-11-15 14:00 ` David Botton
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox