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.236.149.170 with SMTP id x30mr5645731yhj.20.1376068199307; Fri, 09 Aug 2013 10:09:59 -0700 (PDT) X-Received: by 10.182.242.109 with SMTP id wp13mr2384obc.19.1376068199218; Fri, 09 Aug 2013 10:09:59 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!usenet.blueworldhosting.com!feeder02.blueworldhosting.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!fx3no1810016qab.0!news-out.google.com!he10ni1155qab.0!nntp.google.com!fx3no1810008qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 9 Aug 2013 10:09:58 -0700 (PDT) In-Reply-To: <87ob96ajv6.fsf@VLAN-3434.student.uu.se> 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> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <03ea570b-e45f-4694-ab9b-3413c4770379@googlegroups.com> Subject: Re: 4 beginner's questions on the PL Ada From: Adam Beneschan Injection-Date: Fri, 09 Aug 2013 17:09:59 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 3734 Xref: news.eternal-september.org comp.lang.ada:16722 Date: 2013-08-09T10:09:58-07:00 List-Id: On Friday, August 9, 2013 9:50:53 AM UTC-7, Emanuel Berg wrote: > 1. How do you make a constant in Ada? Can I make one that is > computed, for example an integer, set to Milliseconds(something)? Some_Constant : constant integer :=3D . The expression can = be any expression that can be computed. =20 > 2. How do you get options from the CL? I.e., how do you do the C=20 > argv in Ada? Ada.Command_Line. http://www.ada-auth.org/standards/12rm/html/RM-A-15.html =20 > 3. Is it possible to get the task *name* (from the code) into a=20 > string, programatically? That way, a generic procedure could be > used to communicate from tasks, with Put_Line, and without having > to hard code the task name every time. No, not really. One thing to keep in mind is that Ada has task *types*, so= that you can declare a task type and then start any number of tasks of tha= t type. And the tasks don't have to be associated with variables; you can = start an array of tasks: type Task_Array is array (1 .. 10) of Task_Type; T : Task_Array; will start 10 tasks, and they won't really have names. Well, I guess you c= an call them T(1), T(2), ... But tasks can also be record components, and = you can have accesses to tasks, so there really isn't a concept of a "name"= for a task. So if you want to give tasks a name, you'll have to do this i= n the program. > 4. How do you exit Ada altogether? For example, if there are 3=20 > tasks, and one solves the problem, how can I terminate the whole > application at once? (Rather than sending messages to all the > tasks, "OK, we're done looking!") I don't recommend having one task kill the entire program. Ada allows you = to define types that have finalization procedures associated with them (e.g= . for a file, you might want a finalization procedure that makes sure any r= emaining data is flushed to the file). Ada makes sure that when a procedur= e or task is exited, anything that needs to be finalized will be finalized.= Performing an operation that just exits the program suddenly will subvert= that. There's an "abort" statement to allow one task to terminate other t= asks; that *does* ensure that finalization takes place. But overall, I thi= nk it's better to do things cleanly; one way is to send a message to the ot= her tasks with entry calls, but you can also create a variable (or a protec= ted object) that's accessible to all tasks that they can check at certain p= oints to see if they can quit. -- Adam