exit ?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

exit ?

Tony Pelton
hi all,

new pascal guy, but not a new programmer.

i'm used to being able to use the "return" reserved word in Java and
'C' to be able to short circuit the execution of a function/method.

over and above any philisophical judgments on my programming
technique, I see Free Pascal has a reserved word 'exit' that mimics
"return" ?

Is some analogy to "return" not supported in the official pascal dialect ?

is 'exit' the only way to do this, and obviously, not portable to
other compilers ?

is there another token that i could/should use ?

i do know that there is goto/label, but i would prefer not to use
that, as that construct has been beat into my head over the years as
being very bad.

tia,
Tony

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: exit ?

Jonas Maebe

On 25 mei 2005, at 18:20, Tony Pelton wrote:

> over and above any philisophical judgments on my programming
> technique, I see Free Pascal has a reserved word 'exit' that mimics
> "return" ?

Yes.

> Is some analogy to "return" not supported in the official pascal
> dialect ?

exit with a parameter is not supported in other compilers afaik (e.g.
exit(5), equivalent to "return 5"). It may exist in Delphi (I've never
used Delphi), but it definitely does not exist in Turbo Pascal.

> is 'exit' the only way to do this, and obviously, not portable to
> other compilers ?

Exit without a parameter is supported in Turbo Pascal and Delphi.

> is there another token that i could/should use ?

Not that I can think of.


Jonas


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: exit ?

Paul Davidson
Perhaps combinations of RESULT and EXIT may help?
   if TimeToLeave then begin
     Result := 5;
     Exit;
   end else ....

On May 25, 2005, at 12:33, Jonas Maebe wrote:

>
> On 25 mei 2005, at 18:20, Tony Pelton wrote:
>
>> over and above any philisophical judgments on my programming
>> technique, I see Free Pascal has a reserved word 'exit' that mimics
>> "return" ?
>
> Yes.
>
>> Is some analogy to "return" not supported in the official pascal
>> dialect ?
>
> exit with a parameter is not supported in other compilers afaik (e.g.
> exit(5), equivalent to "return 5"). It may exist in Delphi (I've never
> used Delphi), but it definitely does not exist in Turbo Pascal.
>
>> is 'exit' the only way to do this, and obviously, not portable to
>> other compilers ?
>
> Exit without a parameter is supported in Turbo Pascal and Delphi.
>
>> is there another token that i could/should use ?
>
> Not that I can think of.
>
>
> Jonas
>
>
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
P Davidson
Corax Networks Inc.
http://CoraxNetworks.com

IMPORTANT NOTICE:  This message is intended only for the use of the
individual or entity to which it is addressed. The message may contain
information that is privileged, confidential and exempt from disclosure
under applicable law.  If the reader of this message is not the
intended recipient, or the employee or agent responsible for delivering
the message to the intended recipient, you are notified that any
dissemination, distribution or copying of this communication is
strictly prohibited.  If you have received this communication in error,
please notify Corax Networks immediately by email at
[hidden email].  Thank you.


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: exit ?

Adriaan van Os-2
In reply to this post by Jonas Maebe
Jonas Maebe wrote:

>> Is some analogy to "return" not supported in the official pascal
>> dialect ?
>
> exit with a parameter is not supported in other compilers afaik (e.g.
> exit(5), equivalent to "return 5").

UCSD Pascal has

EXIT( procedurename)
EXIT( programname)
EXIT( PROGRAM)

Macintosh Pascal compilers support EXIT( procedurename) and EXIT(
PROGRAM). EXIT( procedurename) has been implemented in GNU Pascal
recently.

>> is 'exit' the only way to do this, and obviously, not portable to
>> other compilers ?
>
> Exit without a parameter is supported in Turbo Pascal and Delphi.

Delphi has the built-in "Result" variable and GNU Pascal (also) has
"Return".

Regards,

Adriaan van Os


_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: exit ?

L505
In reply to this post by Paul Davidson
One could wonder whether return really exits or not. I guess exit is more obvious.
ReturnAndExit is a bit verbose I suppose.

Another thing to do is go

result:=5; Exit;

on the same line

Lars
----- Original Message -----
From: "Paul Davidson" <[hidden email]>
To: "FPC-Pascal users discussions" <[hidden email]>
Sent: Wednesday, May 25, 2005 9:39 AM
Subject: Re: [fpc-pascal] exit ?


| Perhaps combinations of RESULT and EXIT may help?
|    if TimeToLeave then begin
|      Result := 5;
|      Exit;
|    end else ....
|
| On May 25, 2005, at 12:33, Jonas Maebe wrote:
|
| >
| > On 25 mei 2005, at 18:20, Tony Pelton wrote:
| >
| >> over and above any philisophical judgments on my programming
| >> technique, I see Free Pascal has a reserved word 'exit' that mimics
| >> "return" ?
| >
| > Yes.
| >
| >> Is some analogy to "return" not supported in the official pascal
| >> dialect ?
| >
| > exit with a parameter is not supported in other compilers afaik (e.g.
| > exit(5), equivalent to "return 5"). It may exist in Delphi (I've never
| > used Delphi), but it definitely does not exist in Turbo Pascal.
| >
| >> is 'exit' the only way to do this, and obviously, not portable to
| >> other compilers ?
| >
| > Exit without a parameter is supported in Turbo Pascal and Delphi.
| >
| >> is there another token that i could/should use ?
| >
| > Not that I can think of.
| >
| >
| > Jonas
| >
| >
| > _______________________________________________
| > fpc-pascal maillist  -  [hidden email]
| > http://lists.freepascal.org/mailman/listinfo/fpc-pascal
| >
| >
| P Davidson
| Corax Networks Inc.
| http://CoraxNetworks.com
|
| IMPORTANT NOTICE:  This message is intended only for the use of the
| individual or entity to which it is addressed. The message may contain
| information that is privileged, confidential and exempt from disclosure
| under applicable law.  If the reader of this message is not the
| intended recipient, or the employee or agent responsible for delivering
| the message to the intended recipient, you are notified that any
| dissemination, distribution or copying of this communication is
| strictly prohibited.  If you have received this communication in error,
| please notify Corax Networks immediately by email at
| [hidden email].  Thank you.
|
|
| _______________________________________________
| fpc-pascal maillist  -  [hidden email]
| http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: exit ?

Marco van de Voort
In reply to this post by Jonas Maebe
> exit with a parameter is not supported in other compilers afaik (e.g.
> exit(5), equivalent to "return 5"). It may exist in Delphi

Not in D6-D7 to my knowledge. D2005 unknown.

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Loading...