comp.lang.ada
 help / color / mirror / Atom feed
From: "Ashley Manos" <atm@picknowl.com.au>
Subject: Generic Packages in Ada
Date: 2000/08/10
Date: 2000-08-10T00:00:00+00:00	[thread overview]
Message-ID: <39926569@newsserver1.picknowl.com.au> (raw)

Hi - can anyone help me with this:

I'm attempting to write a generic package for linked lists in Ada.
The data structure I'm looking to make generic is the element
ie each element in the list is composed of 2 parts: the elemtn and a pointer
to the next element.

So my package spec looks something like this:

generic
    type Node is private;            -- here's the list element
    type List is access Node;    -- here's the pointer to the next element
in the list

package Lists is
    function CreateList(N:in Node) return List;
    procedure AddToRear(N:in Node; L:in out List);
    procedure RemoveFirst(N:in Node; L:in out List);
end Lists;

However, the compiler is complaining (and rightly so!) about my package
body, the start of which looks like this:

package body Lists is

    function CreateList(N:in Node) return List is
        L:List;
    begin
        L:= new Node;
        L.Next:= Null;    ***
        return L;
    end CreateList;

    ............... etc ..................

The compiler is saying "invalid prefix in selected component L" about the
line ***.
I can see why the compiler is raising this error, but I need my function to
refer to the "Next" component of the element, as it will be of type "List"
ie the pointer to the next element.

If this makes absolutely any sense to anybody that might be able to help,
could you PLEASE reply.

Thanks
Ashley (atm@picknowl.com.au)






             reply	other threads:[~2000-08-10  0:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-10  0:00 Ashley Manos [this message]
2000-08-10  0:00 ` Generic Packages in Ada JMS
2000-08-10  0:00 ` Samuel T. Harris
2000-08-11  0:00   ` Martin Dowie
2000-08-14  0:00     ` Samuel T. Harris
2000-08-14  0:00       ` Ada 83 Booch [was Generic Packages in Ada] Vincent Marciante
2000-08-10  0:00 ` Generic Packages in Ada David C. Hoos, Sr.
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox