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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.224.173.4 with SMTP id n4mr11911002qaz.3.1376091232199; Fri, 09 Aug 2013 16:33:52 -0700 (PDT) X-Received: by 10.50.111.48 with SMTP id if16mr250674igb.3.1376091232009; Fri, 09 Aug 2013 16:33:52 -0700 (PDT) Path: border1.nntp.ams3.giganews.com!border1.nntp.ams2.giganews.com!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!nntp.giganews.com!news.astraweb.com!border5.a.newsrouter.astraweb.com!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!novso.com!nerim.net!usenet-fr.net!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!fx3no1841425qab.0!news-out.google.com!he10ni1155qab.0!nntp.google.com!fx3no1841409qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Aug 2013 16:33:51 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=RxNzCgoAAACA5KmgtFQuaU-WaH7rjnAO NNTP-Posting-Host: 66.126.103.122 References: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> <878v0aee8i.fsf@VLAN-3434.student.uu.se> <87ob96cxm8.fsf@VLAN-3434.student.uu.se> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <92c32083-74f2-4aaa-94cc-9c9e882bfdf4@googlegroups.com> Subject: Re: 4 beginner's questions on the PL Ada From: Adam Beneschan Injection-Date: Fri, 09 Aug 2013 23:33:52 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3532 X-Original-Bytes: 3967 Xref: number.nntp.dca.giganews.com comp.lang.ada:182913 Date: 2013-08-09T16:33:51-07:00 List-Id: On Friday, August 9, 2013 3:47:27 PM UTC-7, Alan Jump wrote: > On Friday, August 9, 2013 3:36:52 PM UTC-7, Robert A Duff wrote: > Umm...I'm a neophyte when it comes to Ada, but the example you gave doesn= 't register with me as being valid. I read that as three separate allocatio= ns in a row of Some_Task_Type to the same variable name, and logic would te= ll me that with each new allocation, the previous allocation terminates No. First of all, if you do this on other record types: X :=3D new Record1; X :=3D new Record1; X :=3D new Record1; the memory allocated for the first Record1 doesn't get released when the se= cond X is allocated, and so on. The data is still there in memory. And it= needs to be, in case there was some code in between those allocations that= caused something else to point to the record (or to one of its components)= in between. You can't automatically destroy the record objects if somethi= ng else might be pointing to them. But even if nothing else was pointing to them (as in the above example), Ad= a still doesn't mandate garbage collection--i.e. reclaiming storage that no= thing points to. A compiler *could* generate code to do this automatically= , but I don't know of any that do. Generally, you have to do your own memo= ry management (using Unchecked_Deallocation). So if you can see that in th= e above example, memory storage won't automatically be reclaimed, you can s= ee by analogy that tasks won't automatically be terminated either. =20 But there's another factor: if you allocate a task (or a record containing = a task), using Unchecked_Deallocation (or automatic memory reclamation) won= 't terminate the task. That's just the way the language authors decided. = This discussion has come up before, and it's surprised other people that a = task will still run after Unchecked_Deallocation has been used on it, but t= here were reasons why things are the way they are. I don't remember the re= asons, though.=20 -- Adam