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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d142408257dde54c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-29 14:08:35 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!diablo.netcom.net.uk!netcom.net.uk!tank.news.pipex.net!pipex!newspeer.clara.net!news.clara.net!news5-gui.server.ntli.net!ntli.net!news11-gui.server.ntli.net.POSTED!not-for-mail Reply-To: "Liddle Feesh" From: "Liddle Feesh" Newsgroups: comp.lang.ada References: Subject: Re: Can someone help me understand this queue package? X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: Date: Sat, 29 Dec 2001 22:02:03 -0000 NNTP-Posting-Host: 213.105.185.39 X-Complaints-To: abuse@ntlworld.com X-Trace: news11-gui.server.ntli.net 1009663403 213.105.185.39 (Sat, 29 Dec 2001 22:03:23 GMT) NNTP-Posting-Date: Sat, 29 Dec 2001 22:03:23 GMT Organization: ntl Cablemodem News Service Xref: archiver1.google.com comp.lang.ada:18392 Date: 2001-12-29T22:02:03+00:00 List-Id: "Michal Nowak" wrote: > "ADA 95: THE CRAFT OF OBJECT-ORIENTED PROGRAMMING" - chapter 11 > (in particular - 11.4) Okay. In the example given from that page - adding a new "Node" or "Appoinment" would be done using the procedure (in my example) "Add". This procedure is listed as follows: procedure add (n: in integer; q: in out queue) is begin null; -- Do nothing end add; Now - in the example from the site: New_Item := new Appointment_Record; if Current /= null then -- insert after another appointment New_Item.Next := Current.Next; Current.Next := New_Item; else -- insert at start of list New_Item.Next := Diary.First; Diary.First := New_Item; end if; But the problem comes when you think, what is "New_Item"? Is it a function call? No - it can't be, no parameters. Is it an instance of a record? Maybe, but my compiler (OE) throws up the error "Direct name, New_Item is not visable" leading me to believe that I haven't instantiated the name somewhere. But what does it instantiate to? And surely when setting up "New_Item", you want to fill it with data - which happens in the example above. But how can you fill it with data when it doesn't exist...? Even if I wrote: New_Item := new Node; This would still fall over with the same error. How do I create a new node, and point the 'next' value to the 'value' of the next node? I know how this is done on paper... V = Value N = Next [V|N]--->[V|N]--->[V|N] -- etc. The last node containing 'null' for the 'next'. But - HOW do I do this? Surely: New_Item := new Node; would work, then all I would have to do is : New_Item.Next := Current.Next; Current.Next := New_Item; (as from the website) But the values for New_Item and Current have not been instantiated. In the example they are not instantiated. In every book I read they are never instantiated. What am I missing here? -- Liddle Feesh ' O 0 o <"//>< ' o'^ (Remove UNDERPANTS to reply)