comp.lang.ada
 help / color / mirror / Atom feed
* Re: exit from a procedure
  2002-07-14  0:14 exit from a procedure Jan Prazak
@ 2002-07-13 21:45 ` chris.danx
  2002-07-13 22:27 ` tmoran
  1 sibling, 0 replies; 8+ messages in thread
From: chris.danx @ 2002-07-13 21:45 UTC (permalink / raw)



"Jan Prazak" <janp9@gmx.net> wrote in message
news:pan.2002.07.13.23.13.01.959431.2074@gmx.net...
> Is it possible to exit from a procedure?

use
    return;







^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-14  0:14 exit from a procedure Jan Prazak
  2002-07-13 21:45 ` chris.danx
@ 2002-07-13 22:27 ` tmoran
  2002-07-14 21:16   ` Jan Prazak
  1 sibling, 1 reply; 8+ messages in thread
From: tmoran @ 2002-07-13 22:27 UTC (permalink / raw)


>And is it possible to stop the whole program? It's "halt" in
>Pascal, but it doesn't work in Ada, so maybe there is another name for it.
  One way is to raise, but never handle, an exception.  OTOH if you
don't want to exit the program cleanly, but just drop everything in
whatever state it might be, try an OS call.
  Your questions strongly suggest you have no book or tutorial or
sample programs to look at.  Go to www.adapower.com and explore.



^ permalink raw reply	[flat|nested] 8+ messages in thread

* exit from a procedure
@ 2002-07-14  0:14 Jan Prazak
  2002-07-13 21:45 ` chris.danx
  2002-07-13 22:27 ` tmoran
  0 siblings, 2 replies; 8+ messages in thread
From: Jan Prazak @ 2002-07-14  0:14 UTC (permalink / raw)


Is it possible to exit from a procedure?

I am using a label, but it's not a good solution, because there a
statement must follow, so I have to say "X := 0;" or something after the
label.

....
.... goto Big_End;
....

<<Big_End>> X := 0;
end procedure_name;

It is easy in Pascal (with "exit"), so I think it must also work in Ada.

And is it possible to stop the whole program? It's "halt" in
Pascal, but it doesn't work in Ada, so maybe there is another name for it.


Jan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-13 22:27 ` tmoran
@ 2002-07-14 21:16   ` Jan Prazak
  2002-07-15 12:14     ` Steve Sangwine
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Prazak @ 2002-07-14 21:16 UTC (permalink / raw)


1st answer:

return; ?? In a procedure? I will try it.

2nd:
> One way is to raise, but never handle, an exception.  OTOH if you
> don't want to exit the program cleanly, but just drop everything in
> whatever state it might be, try an OS call.
>   Your questions strongly suggest you have no book or tutorial or
> sample programs to look at.  Go to www.adapower.com and explore.

I have some tutorials, but I'm still reading the first one, it takes much
time...

thanks,
Jan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-14 21:16   ` Jan Prazak
@ 2002-07-15 12:14     ` Steve Sangwine
  2002-07-15 19:10       ` Jan Prazak
  0 siblings, 1 reply; 8+ messages in thread
From: Steve Sangwine @ 2002-07-15 12:14 UTC (permalink / raw)


On Sun, 14 Jul 2002 22:16:28 +0100, Jan Prazak <janp9@gmx.net> wrote:

>1st answer:
>
>return; ?? In a procedure? I will try it.

The return (or RETURN) statement has been the absolutely standard way
of returning from a procedure in many  languages (e.g. FORTRAN 66,
BASIC) for decades. So why the ???? marks? Many assembler languages
also use return for exit from a subroutine (sometimes the mnemonic is
RTS - return from subroutine, sometimes it is RETURN or RET), but the
terminology is the same nevertheless. Maybe it would be a good idea to
learn a bit about programming history .....

(Note also that it is possible to exit from an Ada main program using
return, since an Ada main program is a procedure.)

Steve Sangwine




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-15 12:14     ` Steve Sangwine
@ 2002-07-15 19:10       ` Jan Prazak
  2002-07-16  8:30         ` Gautier
  0 siblings, 1 reply; 8+ messages in thread
From: Jan Prazak @ 2002-07-15 19:10 UTC (permalink / raw)


On Mon, 15 Jul 2002 11:14:26 -0100, Steve Sangwine wrote:


> The return (or RETURN) statement has been the absolutely standard way of
> returning from a procedure in many  languages (e.g. FORTRAN 66, BASIC)
> for decades. So why the ???? marks?

Because "return" is used in Ada for returning a value from a function, so
using the same keyword in a procedure looks strange. But there it's of
course without a value. But it's ok now, now I understand that "return"
in a procedure doesn't mean "return a value", but just "return" in the
meaning of "go back" to caller.
But I think it's clearer in Pascal, there it's "exit" (a loop exit is
called "quit" there).

> Maybe it would be a good idea to
> learn a bit about programming history .....

No, thanks... I don't have the time to learn dead languages, but it could
be interesting, indeed (but probably also frustrating, I have seen Towers
Of Hanoi in 10 different languages, some of the code had 10 lines
(Pascal, C...) and some even 100 lines).

Jan




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-15 19:10       ` Jan Prazak
@ 2002-07-16  8:30         ` Gautier
  2002-07-16 14:08           ` Jan Prazak
  0 siblings, 1 reply; 8+ messages in thread
From: Gautier @ 2002-07-16  8:30 UTC (permalink / raw)


Jan Prazak:

> But I think it's clearer in Pascal, there it's "exit"

I'm afraid you won't find any "exit" in Pascal
( see ISO specification in...
  http://www.moorecad.com/standardpascal/home.html ),
only in some dialects.

>  (a loop exit is called "quit" there).

On which Pascal dialect did you find a "quit" for
exiting loops ? BTW an unfortunate naming if so...
If I rembember well Turbo Pascal 7 and later had a "break".

Anyway, why not make your own "Ada-J" preprocessor to translate
into Ada namings from what you want:
E.g. "take_the_door", "switch_off", "shut_up", etc.

____________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/index.htm#Ada

NB: For a direct answer, address on the Web site!



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: exit from a procedure
  2002-07-16  8:30         ` Gautier
@ 2002-07-16 14:08           ` Jan Prazak
  0 siblings, 0 replies; 8+ messages in thread
From: Jan Prazak @ 2002-07-16 14:08 UTC (permalink / raw)


On Tue, 16 Jul 2002 07:30:21 -0100, Gautier wrote:


>> But I think it's clearer in Pascal, there it's "exit"
> 
> I'm afraid you won't find any "exit" in Pascal ( see ISO specification
> in...
>   http://www.moorecad.com/standardpascal/home.html ),
> only in some dialects.

I mean Turbo Pascal, not ISO Pascal.
 
>>  (a loop exit is called "quit" there).
> 
> On which Pascal dialect did you find a "quit" for exiting loops ? BTW an
> unfortunate naming if so... If I rembember well Turbo Pascal 7 and later
> had a "break".

yes, you're right, it's break



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2002-07-16 14:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-14  0:14 exit from a procedure Jan Prazak
2002-07-13 21:45 ` chris.danx
2002-07-13 22:27 ` tmoran
2002-07-14 21:16   ` Jan Prazak
2002-07-15 12:14     ` Steve Sangwine
2002-07-15 19:10       ` Jan Prazak
2002-07-16  8:30         ` Gautier
2002-07-16 14:08           ` Jan Prazak

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