comp.lang.ada
 help / color / mirror / Atom feed
* Generic Packages in Ada
@ 2000-08-10  0:00 Ashley Manos
  2000-08-10  0:00 ` Samuel T. Harris
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ashley Manos @ 2000-08-10  0:00 UTC (permalink / 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)






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-08-14  0:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-10  0:00 Generic Packages in Ada Ashley Manos
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.
2000-08-10  0:00 ` JMS

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