* Re: [student help] Won't allow package body. [not found] <35514AAC.D46B535C@iinet.net.au> @ 1998-05-07 0:00 ` David C. Hoos, Sr. 1998-05-13 0:00 ` MSG 1 sibling, 0 replies; 3+ messages in thread From: David C. Hoos, Sr. @ 1998-05-07 0:00 UTC (permalink / raw) Oliver White wrote in message <35514AAC.D46B535C@iinet.net.au>... >I'm compiling a package, the ads file begins as so - > >> generic >> type ObjectType is private; >> package LinkedListPackage is >> >but when I compile, I get this message - > >"generic package LinkedListPackage does not allow a body" > This is either one of two things: 1. The package does not allow a body because none is required -- e.g., the package spec defines no subprogram, so no body is required. If no body is required, none is allowed. 2. There is an error of some sort in the code which prevents error-free compilation of the package spec. Then, in may cases you will get this error. In general, you need to provide a complete compilation unit in your request for help, because there is not enough information in an incomplete code snippet such as you have supplied to answer your question. Also, as a general rule, you should tell us what is the compiler and version you are using, and on what platform. With complete information, I' sure one of us will be glad to help. David C. Hoos, Sr. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [student help] Won't allow package body. [not found] <35514AAC.D46B535C@iinet.net.au> 1998-05-07 0:00 ` [student help] Won't allow package body David C. Hoos, Sr. @ 1998-05-13 0:00 ` MSG 1998-05-13 0:00 ` Brian Rogoff 1 sibling, 1 reply; 3+ messages in thread From: MSG @ 1998-05-13 0:00 UTC (permalink / raw) Besides the fact that Davic C Hoos, Sr. is correct and that you need to provide a more complete example... Assuming that your spec is compilable but doesn't require a body (a generic with no body?...I'll have to think about that later)...you can force need for a body by adding a dummy procedure with no code OR you can specify "pragma Elaborate_Body;" in the spec of the generic pacakge. Michael Garnett Oliver White <ojw@iinet.net.au> wrote in message 35514AAC.D46B535C@iinet.net.au... I'm compiling a package, the ads file begins as so - generic type ObjectType is private; package LinkedListPackage is but when I compile, I get this message - "generic package LinkedListPackage does not allow a body" I'm sure there's an obvious error, could you help me? Oliver White. ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [student help] Won't allow package body. 1998-05-13 0:00 ` MSG @ 1998-05-13 0:00 ` Brian Rogoff 0 siblings, 0 replies; 3+ messages in thread From: Brian Rogoff @ 1998-05-13 0:00 UTC (permalink / raw) On Wed, 13 May 1998, MSG wrote: > Besides the fact that Davic C Hoos, Sr. is correct and that you need to > provide a more complete example... > > Assuming that your spec is compilable but doesn't require a body (a generic > with no body?...I'll have to think about that later)...you can force need Bodiless generics are part of a very powerful Ada programming idiom. Using them we can decouple interfaces (signatures) from implementations. For example, here is a pseudo-Ada outline of a sequence type, showing roughly how it might be used. generic type Item_Type is private; type Position_Type is private; type Sequence_Type is private; with procedure Initialize (Seq : out Sequence_Type); with function Is_Empty (Seq : Sequence_Type) return Boolean is private; with function Is_Done (Seq : Sequence_Type; Pos : Position_Type) return Boolean is private; package Sequence_Sig is -- Here is your bodiless generic! end; generic type Item_Type is private; package Lists is type Position_Type is private; type List_Type is private; with procedure Initialize (Seq : out Sequence_Type); with function Is_Empty (Seq : Sequence_Type) return Boolean; with function Is_Done (Seq : Sequence_Type; Pos : Position_Type) return Boolean; with function Get_Value_At (Seq : Sequence_Type; Pos : Position_Type) return Item_Type; with function Succ (Pos : Position_Type) return Position_Type; private -- Singly linked list implementation end; package Integer_Lists is new Lists(Item_Type => Integer); package Integer_Seqs is new Sequences(Item_Type => Integer_Lists.Item_Type, Position_Type => Integer_Lists.Position_Type, Sequence_Type => Integer_Lists.List_Type, Initialize => Integer_Lists.Initialize ... etc... ); generic with Concrete_Seqs is new Sequences(<>); package Concrete_Algorithms is ... end Concrete_Algorithms; A client package like Concrete_Algorithms will only depend on the Signature and so you can substitute arrays or lists or vectors or whatever as your sequence. -- Brian > for a body by adding a dummy procedure with no code OR you can specify > "pragma Elaborate_Body;" in the spec of the generic pacakge. > > Michael Garnett > > Oliver White <ojw@iinet.net.au> wrote in message > 35514AAC.D46B535C@iinet.net.au... > I'm compiling a package, the ads file begins as so - > > > generic > > type ObjectType is private; > > package LinkedListPackage is > but when I compile, I get this message - > "generic package LinkedListPackage does not allow a body" > > I'm sure there's an obvious error, could you help me? > > Oliver White. > > > > > ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-05-13 0:00 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <35514AAC.D46B535C@iinet.net.au> 1998-05-07 0:00 ` [student help] Won't allow package body David C. Hoos, Sr. 1998-05-13 0:00 ` MSG 1998-05-13 0:00 ` Brian Rogoff
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox