comp.lang.ada
 help / color / mirror / Atom feed
From: "Liddle Feesh" <no_see_reply_address@spam.com>
Subject: Re: Can someone help me understand this queue package?
Date: Sat, 29 Dec 2001 22:02:03 -0000
Date: 2001-12-29T22:02:03+00:00	[thread overview]
Message-ID: <L4rX7.11472$Zg2.517773@news11-gui.server.ntli.net> (raw)
In-Reply-To: mailman.1009625522.9105.comp.lang.ada@ada.eu.org

"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)







  parent reply	other threads:[~2001-12-29 22:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-12-28 17:14 Can someone help me understand this queue package? Liddle Feesh
2001-12-28 18:16 ` Michal Nowak
2001-12-28 22:57   ` Liddle Feesh
2001-12-29 11:35     ` Michal Nowak
2001-12-29 19:37       ` Liddle Feesh
2001-12-29 20:05         ` Michal Nowak
2001-12-29 20:44           ` Liddle Feesh
2001-12-29 22:02       ` Liddle Feesh [this message]
2001-12-30 13:14         ` Michal Nowak
2001-12-30 22:28           ` Liddle Feesh
2001-12-31 10:32             ` Michal Nowak
2001-12-29 17:13   ` Liddle Feesh
2001-12-29 18:42     ` martin.m.dowie
2001-12-29 19:09       ` Liddle Feesh
2001-12-29 17:13   ` Liddle Feesh
2001-12-29 17:13   ` Liddle Feesh
2001-12-29 17:14     ` Liddle Feesh
2001-12-29 17:39     ` Liddle Feesh
replies disabled

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