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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,33d86ea4039d454a X-Google-Attributes: gid103376,public From: Brian Rogoff Subject: Re: [student help] Won't allow package body. Date: 1998/05/13 Message-ID: #1/1 X-Deja-AN: 352955133 References: <35514AAC.D46B535C@iinet.net.au> <6jcfln$ft$1@news.eclipse.net> Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: 895085523 3089 bpr 206.184.139.132 Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-05-13T00:00:00+00:00 List-Id: 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 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. > > > > >