From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Tasking issues
Date: Mon, 13 Aug 2007 11:22:46 +0200
Date: 2007-08-13T11:18:30+02:00 [thread overview]
Message-ID: <1ilz4m777fqa5.lmji3020dpvu$.dlg@40tude.net> (raw)
In-Reply-To: O6Lvi.32007$ax1.21997@bgtnsc05-news.ops.worldnet.att.net
On Sun, 12 Aug 2007 21:39:58 GMT, anon wrote:
> First the 'ABORT' statement is a legal statement. Yes, there are better
> ways to terminate the task, but that would mean a complete overhaul of
> shaunpatterson's program, which could confuse shaunpatterson.
No, it is using abort, which is confusing in a small illustrative program.
There is no need to abort tasks in almost any Ada program.
> Also any statement that is valid in the language is valid in the code. And
> the people who say 'ABORT' statement is bad are just like the guys who
> said that "GOTO" in other languages
Ada has goto, see ARM 5.8.
> or Ada's 'LOOP' statement is bad.
> Since "GOTO' or 'LOOP' statements are a high-level language version of
> the 'JMP' assembly instruction.
Yes, yes. NASA is training astronauts climbing trees, that makes them
closer to the moon. Everything is Turing Complete. Equivalence of programs
proves nothing.
> As for "Get_Line immediately", thats an error, The Ada code can not
> force the operating system or keyboard routine to abort.
Of course it can, on most operating systems you can wait for a
or-combination of events, you can also close the file handle from outside
and that will abort pending I/O etc. It is technically possible, though,
AFAIK, RM does not require Get_Line being abortable. Yet it is to expect in
a decent implementation.
[...]
> Also where is your example of how the code should be written without a
> complete overhaul of shaunpatterson's program. Only simple additions or ]
> changes with some comment for him.
You mean your code or one of the OP? Your code can be rewritten without
aborts and global variables:
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Text_IO; use Ada.Text_IO;
procedure Main is
task Get_Name is
entry Shut_Down;
end Get_Name;
task Print_Something is
entry Shut_Down;
end Print_Something;
task body Get_Name is
Name : String (1..25);
Index : Positive;
Got_It : Boolean;
begin
Get_Line : loop
Index := Name'First;
loop
select
accept Shut_Down;
exit Get_Line;
else
Get_Immediate (Name (Index), Got_It);
end select;
if Got_It then
exit when Name (Index) = CR;
if Index < Name'Last then
Index := Index + 1;
end if;
end if;
end loop;
if Index = Name'Last then
Put_Line ("Input (truncated):" & Name (1..Index - 1));
else
Put_Line ("Input:" & Name (1..Index - 1));
end if;
end loop Get_Line;
end Get_Name;
task body Print_Something is
begin
loop
select
accept Shut_Down;
exit;
else
Put_Line ("blah...");
end select;
end loop ;
end Print_Something;
begin
delay 1.0;
Get_Name.Shut_Down;
Print_Something.Shut_Down;
end Main;
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2007-08-13 9:22 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-11 17:03 Tasking issues shaunpatterson
2007-08-11 18:42 ` Dmitry A. Kazakov
2007-08-12 11:06 ` Simon Wright
2007-08-12 12:05 ` Dmitry A. Kazakov
2007-08-12 17:12 ` shaunpatterson
2007-08-12 18:03 ` Dmitry A. Kazakov
2007-08-12 22:10 ` Jeffrey R. Carter
2007-08-13 19:54 ` Simon Wright
2007-08-13 22:30 ` shaunpatterson
2007-08-14 7:10 ` Tasking issues => Book List anon
[not found] ` <13bulskfjvogv8e@corp.supernews.com>
2007-08-12 20:20 ` Tasking issues Simon Wright
2007-08-11 18:51 ` jimmaureenrogers
2007-08-11 19:08 ` Jeffrey R. Carter
2007-08-11 22:31 ` Steve
2007-08-12 9:00 ` anon
2007-08-12 9:43 ` Dmitry A. Kazakov
2007-08-12 21:39 ` anon
2007-08-12 22:15 ` Jeffrey R. Carter
2007-08-13 9:13 ` anon
2007-08-13 19:37 ` Simon Wright
2007-08-13 20:17 ` Markus E.L. 2
2007-08-14 0:40 ` Jeffrey R. Carter
2007-08-13 9:22 ` Dmitry A. Kazakov [this message]
2007-08-13 12:41 ` Larry Kilgallen
2007-08-13 13:22 ` Dmitry A. Kazakov
2007-08-12 21:03 ` Maciej Sobczak
2007-08-12 22:07 ` Jeffrey R. Carter
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox