From: tmoran@acm.org
Subject: Re: Package instantiation and automatic de-allocation.
Date: Mon, 23 Dec 2002 06:22:44 GMT
Date: 2002-12-23T06:22:44+00:00 [thread overview]
Message-ID: <UYxN9.309735$GR5.100619@rwcrnsc51.ops.asp.att.net> (raw)
In-Reply-To: fUwN9.9541$p_6.746832@bgtnsc04-news.ops.worldnet.att.net
> Your package below does not work because it lacks a public
> declaration for your Stack type. Once you have a name for the
> type you must pass an instance of that type to each function and
> procedure. Ada does not have an impicit "this" variable like C++ or
> Java.
That's true if you want to allow multiple Stack objects, perhaps
arrays of Stacks, etc. Sometimes you really only want one or very
few objects, so one/generic instantiation is good. For instance,
say you have a space rocket with two similar radios, one of which
talks to Earth and the other to your Moon base. You might then
generic
Hardware_Port : Natural;
package Communications is ...
procedure Send(...);
procedure Receive(...);
...
package Earth is new Communications(Port=>16#378#);
package Moon is new Communications(Port=>16#278#);
Then you can say
Earth.Send(...);
Moon.Receive(...);
But if you had 4 moon bases, you would have to
package Moon_1 is new Communications(...
package Moon_2 is new Communications(...
package Moon_3 is new Communications(...
package Moon_4 is new Communications(...
you couldn't make an array Moon(1 .. 4).
> without having to dick with Unchecked_Deallocation.
If you never say "X := new ...", you never have to use
Unchecked_Deallocation. If you declare an object or do a generic
instantiation in a declare, it will automagically be deallocated
when you leave that scope.
next prev parent reply other threads:[~2002-12-23 6:22 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-23 4:42 Package instantiation and automatic de-allocation Stapler
2002-12-23 5:09 ` James S. Rogers
2002-12-23 6:22 ` tmoran [this message]
2002-12-24 21:57 ` Stapler
[not found] ` <j1cbua.fpc.ln@beastie.ix.netcom.com>
2002-12-25 23:56 ` Stapler
[not found] ` <amndua.f24.ln@beastie.ix.netcom.com>
2003-01-13 15:43 ` John English
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox