tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
3
Task/Program-termination/0DESCRIPTION
Normal file
3
Task/Program-termination/0DESCRIPTION
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Show the syntax for a complete stoppage of a program inside a [[Conditional Structures|conditional]]. This includes all [[threads]]/[[processes]] which are part of your program.
|
||||
|
||||
Explain the cleanup (or lack thereof) caused by the termination (allocated memory, database connections, open files, object finalizers/destructors, run-on-exit hooks, etc.). Unless otherwise described, no special cleanup outside that provided by the operating system is provided.
|
||||
2
Task/Program-termination/1META.yaml
Normal file
2
Task/Program-termination/1META.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
note: Basic language learning
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
IF problem = 1 THEN
|
||||
stop
|
||||
FI
|
||||
1
Task/Program-termination/AWK/program-termination.awk
Normal file
1
Task/Program-termination/AWK/program-termination.awk
Normal file
|
|
@ -0,0 +1 @@
|
|||
if(problem)exit 1
|
||||
10
Task/Program-termination/Ada/program-termination-1.ada
Normal file
10
Task/Program-termination/Ada/program-termination-1.ada
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
with Ada.Task_Identification; use Ada.Task_Identification;
|
||||
|
||||
procedure Main is
|
||||
-- Create as many task objects as your program needs
|
||||
begin
|
||||
-- whatever logic is required in your Main procedure
|
||||
if some_condition then
|
||||
Abort_Task (Current_Task);
|
||||
end if;
|
||||
end Main;
|
||||
11
Task/Program-termination/Ada/program-termination-2.ada
Normal file
11
Task/Program-termination/Ada/program-termination-2.ada
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
procedure Main is
|
||||
-- Create as many task objects as your program needs
|
||||
begin
|
||||
-- whatever logic is required in your Main procedure
|
||||
if some_condition then
|
||||
-- for each task created by the Main procedure
|
||||
The_task.Stop;
|
||||
-- end the Main procedure
|
||||
return; -- actually, this is not needed
|
||||
end if;
|
||||
end Main;
|
||||
14
Task/Program-termination/Ada/program-termination-3.ada
Normal file
14
Task/Program-termination/Ada/program-termination-3.ada
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
task body Some_Task is
|
||||
begin
|
||||
loop
|
||||
select
|
||||
-- Some alternatives
|
||||
...
|
||||
or accept Stop do
|
||||
-- Some cleanup while holding the caller is here
|
||||
end Stop;
|
||||
-- A cleanup asynchronous to the caller is here
|
||||
exit; -- We are through
|
||||
end select
|
||||
end loop;
|
||||
end Some_Task;
|
||||
10
Task/Program-termination/Ada/program-termination-4.ada
Normal file
10
Task/Program-termination/Ada/program-termination-4.ada
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
task body Some_Task is
|
||||
begin
|
||||
loop
|
||||
select
|
||||
-- Some alternatives
|
||||
...
|
||||
or terminate; -- We are through
|
||||
end select
|
||||
end loop;
|
||||
end Some_Task;
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
on run
|
||||
If problem then return
|
||||
end run
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
on run
|
||||
f()
|
||||
display dialog "This message will never be displayed."
|
||||
end run
|
||||
|
||||
on f()
|
||||
error
|
||||
end f
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
If (problem)
|
||||
ExitApp
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
If problem Then
|
||||
Exit
|
||||
Endif
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if problem = 1 then
|
||||
end
|
||||
end if
|
||||
|
|
@ -0,0 +1 @@
|
|||
10 IF 1 THEN STOP
|
||||
|
|
@ -0,0 +1 @@
|
|||
10 IF 1 THEN END
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
10 LET a = 1: LET b = 1
|
||||
20 IF a = b THEN GO TO 9995
|
||||
9995 STOP
|
||||
|
|
@ -0,0 +1 @@
|
|||
IF condition% THEN QUIT
|
||||
|
|
@ -0,0 +1 @@
|
|||
if condition exit
|
||||
6
Task/Program-termination/C++/program-termination-1.cpp
Normal file
6
Task/Program-termination/C++/program-termination-1.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <cstdlib>
|
||||
|
||||
void problem_occured()
|
||||
{
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
6
Task/Program-termination/C++/program-termination-2.cpp
Normal file
6
Task/Program-termination/C++/program-termination-2.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <cstdlib>
|
||||
|
||||
void problem_occured()
|
||||
{
|
||||
std::abort();
|
||||
}
|
||||
6
Task/Program-termination/C++/program-termination-3.cpp
Normal file
6
Task/Program-termination/C++/program-termination-3.cpp
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#include <exception>
|
||||
|
||||
void problem_occured()
|
||||
{
|
||||
std::terminate();
|
||||
}
|
||||
18
Task/Program-termination/C/program-termination-1.c
Normal file
18
Task/Program-termination/C/program-termination-1.c
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#include <stdlib.h>
|
||||
/* More "natural" way of ending the program: finish all work and return
|
||||
from main() */
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
/* work work work */
|
||||
...
|
||||
return 0; /* the return value is the exit code. see below */
|
||||
}
|
||||
|
||||
if(problem){
|
||||
exit(exit_code);
|
||||
/* On unix, exit code 0 indicates success, but other OSes may follow
|
||||
different conventions. It may be more portable to use symbols
|
||||
EXIT_SUCCESS and EXIT_FAILURE; it all depends on what meaning
|
||||
of codes are agreed upon.
|
||||
*/
|
||||
}
|
||||
5
Task/Program-termination/C/program-termination-2.c
Normal file
5
Task/Program-termination/C/program-termination-2.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
if(problem){
|
||||
abort();
|
||||
}
|
||||
1
Task/Program-termination/C/program-termination-3.c
Normal file
1
Task/Program-termination/C/program-termination-3.c
Normal file
|
|
@ -0,0 +1 @@
|
|||
exit_group();
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
(if problem
|
||||
(. System exit integerErrorCode))
|
||||
;conventionally, error code 0 is the code for "OK",
|
||||
; while anything else is an actual problem
|
||||
;optionally: (-> Runtime (. getRuntime) (. exit integerErrorCode))
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
(if problem
|
||||
(-> Runtime (. getRuntime) (. halt integerErrorCode)))
|
||||
; conventionally, error code 0 is the code for "OK",
|
||||
; while anything else is an actual problem
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
(defun terminate (status)
|
||||
#+sbcl (sb-ext:quit :unix-status status) ; SBCL
|
||||
#+ccl ( ccl:quit status) ; Clozure CL
|
||||
#+clisp ( ext:quit status) ; GNU CLISP
|
||||
#+cmu ( unix:unix-exit status) ; CMUCL
|
||||
#+abcl ( ext:quit :status status) ; Armed Bear CL
|
||||
#+allegro ( excl:exit status :quiet t) ; Allegro CL
|
||||
(cl-user::quit)) ; Many implementations put QUIT in the sandbox CL-USER package.
|
||||
|
|
@ -0,0 +1 @@
|
|||
System.Halt;
|
||||
|
|
@ -0,0 +1 @@
|
|||
System.Halt(1); // Optional exit code
|
||||
3
Task/Program-termination/E/program-termination-1.e
Normal file
3
Task/Program-termination/E/program-termination-1.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if (true) {
|
||||
interp.exitAtTop()
|
||||
}
|
||||
3
Task/Program-termination/E/program-termination-2.e
Normal file
3
Task/Program-termination/E/program-termination-2.e
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if (true) {
|
||||
interp.exitAtTop("because the task said so")
|
||||
}
|
||||
4
Task/Program-termination/Forth/program-termination.fth
Normal file
4
Task/Program-termination/Forth/program-termination.fth
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
debug @
|
||||
if QUIT \ quit back to the interpreter
|
||||
else BYE \ exit forth environment completely (e.g. end of a Forth shell script)
|
||||
then
|
||||
3
Task/Program-termination/Fortran/program-termination.f
Normal file
3
Task/Program-termination/Fortran/program-termination.f
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
IF (condition) STOP [message]
|
||||
! message is optional and is a character string.
|
||||
! If present, the message is output to the standard output device.
|
||||
|
|
@ -0,0 +1 @@
|
|||
10 IF 1 THEN STOP
|
||||
1
Task/Program-termination/Gema/program-termination.gema
Normal file
1
Task/Program-termination/Gema/program-termination.gema
Normal file
|
|
@ -0,0 +1 @@
|
|||
Star Trek=@err{found a Star Trek reference\n}@abort
|
||||
5
Task/Program-termination/Go/program-termination-1.go
Normal file
5
Task/Program-termination/Go/program-termination-1.go
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
func main() {
|
||||
if problem {
|
||||
return
|
||||
}
|
||||
}
|
||||
46
Task/Program-termination/Go/program-termination-2.go
Normal file
46
Task/Program-termination/Go/program-termination-2.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
const problem = true
|
||||
|
||||
func main() {
|
||||
fmt.Println("main program start")
|
||||
|
||||
// this will get run on exit
|
||||
defer paperwork()
|
||||
|
||||
// this will not run to completion
|
||||
go pcj()
|
||||
|
||||
// this will not get run on exit
|
||||
rec := &requiresExternalCleanup{"external object"}
|
||||
runtime.SetFinalizer(rec, cleanup)
|
||||
|
||||
if problem {
|
||||
fmt.Println("main program returning")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func paperwork() {
|
||||
fmt.Println("i's dotted, t's crossed")
|
||||
}
|
||||
|
||||
func pcj() {
|
||||
fmt.Println("there's uncle Joe")
|
||||
time.Sleep(1e10)
|
||||
fmt.Println("movin kinda slow")
|
||||
}
|
||||
|
||||
type requiresExternalCleanup struct {
|
||||
id string
|
||||
}
|
||||
|
||||
func cleanup(rec *requiresExternalCleanup) {
|
||||
fmt.Println(rec.id, "cleanup")
|
||||
}
|
||||
13
Task/Program-termination/Go/program-termination-3.go
Normal file
13
Task/Program-termination/Go/program-termination-3.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
func main() {
|
||||
fmt.Println("main program start")
|
||||
|
||||
// this will not get run on os.Exit
|
||||
defer func() {
|
||||
fmt.Println("deferred function")
|
||||
}()
|
||||
|
||||
if problem {
|
||||
fmt.Println("main program exiting")
|
||||
os.Exit(-1)
|
||||
}
|
||||
}
|
||||
17
Task/Program-termination/Go/program-termination-4.go
Normal file
17
Task/Program-termination/Go/program-termination-4.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
func pcj() {
|
||||
fmt.Println("at the junction")
|
||||
defer func() {
|
||||
fmt.Println("deferred from pcj")
|
||||
}()
|
||||
panic(10)
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("main program start")
|
||||
defer func() {
|
||||
fmt.Println("deferred from main")
|
||||
}()
|
||||
go pcj()
|
||||
time.Sleep(1e9)
|
||||
fmt.Println("main program done")
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
if (problem) System.exit(intExitCode)
|
||||
|
|
@ -0,0 +1 @@
|
|||
if (problem) Runtime.runtime.halt(intExitCode)
|
||||
8
Task/Program-termination/Haskell/program-termination.hs
Normal file
8
Task/Program-termination/Haskell/program-termination.hs
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import Control.Monad
|
||||
import System.Exit
|
||||
|
||||
when problem do
|
||||
exitWith ExitSuccess -- success
|
||||
exitWith (ExitFailure integerErrorCode) -- some failure with code
|
||||
exitSuccess -- success; in GHC 6.10+
|
||||
exitFailure -- generic failure
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALARM( 999 )
|
||||
3
Task/Program-termination/Icon/program-termination.icon
Normal file
3
Task/Program-termination/Icon/program-termination.icon
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
exit(i) # terminates the program setting an exit code of i
|
||||
stop(x1,x2,..) # terminates the program writing out x1,..; if any xi is a file writing switches to that file
|
||||
runerr(i,x) # terminates the program with run time error 'i' for value 'x'
|
||||
1
Task/Program-termination/J/program-termination-1.j
Normal file
1
Task/Program-termination/J/program-termination-1.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
2!:55^:] condition
|
||||
1
Task/Program-termination/J/program-termination-2.j
Normal file
1
Task/Program-termination/J/program-termination-2.j
Normal file
|
|
@ -0,0 +1 @@
|
|||
3 : 'if. 0~: condition do. 2!:55 condition end.'
|
||||
6
Task/Program-termination/Java/program-termination-1.java
Normal file
6
Task/Program-termination/Java/program-termination-1.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if(problem){
|
||||
System.exit(integerErrorCode);
|
||||
//conventionally, error code 0 is the code for "OK",
|
||||
// while anything else is an actual problem
|
||||
//optionally: Runtime.getRuntime().exit(integerErrorCode);
|
||||
}
|
||||
5
Task/Program-termination/Java/program-termination-2.java
Normal file
5
Task/Program-termination/Java/program-termination-2.java
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
if(problem){
|
||||
Runtime.getRuntime().halt(integerErrorCode);
|
||||
//conventionally, error code 0 is the code for "OK",
|
||||
// while anything else is an actual problem
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
if (some_condition)
|
||||
quit();
|
||||
|
|
@ -0,0 +1 @@
|
|||
if 2 =2 then end
|
||||
6
Task/Program-termination/Logo/program-termination.logo
Normal file
6
Task/Program-termination/Logo/program-termination.logo
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
bye ; exits to shell
|
||||
|
||||
throw "toplevel ; exits to interactive prompt
|
||||
|
||||
pause ; escapes to interactive prompt for debugging
|
||||
continue ; resumes after a PAUSE
|
||||
3
Task/Program-termination/Lua/program-termination.lua
Normal file
3
Task/Program-termination/Lua/program-termination.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if some_condition then
|
||||
os.exit( number )
|
||||
end
|
||||
4
Task/Program-termination/M4/program-termination.m4
Normal file
4
Task/Program-termination/M4/program-termination.m4
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
beginning
|
||||
define(`problem',1)
|
||||
ifelse(problem,1,`m4exit(1)')
|
||||
ending
|
||||
3
Task/Program-termination/MATLAB/program-termination-1.m
Normal file
3
Task/Program-termination/MATLAB/program-termination-1.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if condition
|
||||
return
|
||||
end
|
||||
3
Task/Program-termination/MATLAB/program-termination-2.m
Normal file
3
Task/Program-termination/MATLAB/program-termination-2.m
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if condition
|
||||
quit
|
||||
end
|
||||
|
|
@ -0,0 +1 @@
|
|||
If[problem, Abort[]];
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
/* Basically, it's simply quit() */
|
||||
|
||||
block([ans], loop, if (ans: read("Really quit ? (y, n)")) = 'y
|
||||
then quit()
|
||||
elseif ans = 'n then (print("Nice choice!"), 'done)
|
||||
else (print("I dont' understand..."), go(loop)));
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
/* NetRexx */
|
||||
options replace format comments java crossref symbols nobinary
|
||||
|
||||
extremePrejudice = (1 == 1)
|
||||
if extremePrejudice then do
|
||||
exit extremePrejudice
|
||||
end
|
||||
|
||||
return
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
if problem:
|
||||
quit(QuitFailure)
|
||||
4
Task/Program-termination/OCaml/program-termination.ocaml
Normal file
4
Task/Program-termination/OCaml/program-termination.ocaml
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
if problem then
|
||||
exit integerErrorCode;
|
||||
(* conventionally, error code 0 is the code for "OK",
|
||||
while anything else is an actual problem *)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if(problem) {
|
||||
Runtime->Exit(1);
|
||||
};
|
||||
1
Task/Program-termination/Oz/program-termination.oz
Normal file
1
Task/Program-termination/Oz/program-termination.oz
Normal file
|
|
@ -0,0 +1 @@
|
|||
if Problem then {Application.exit 0} end
|
||||
|
|
@ -0,0 +1 @@
|
|||
if(stuff, quit)
|
||||
2
Task/Program-termination/PHP/program-termination.php
Normal file
2
Task/Program-termination/PHP/program-termination.php
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
if (problem)
|
||||
exit(1);
|
||||
2
Task/Program-termination/PL-I/program-termination-1.pli
Normal file
2
Task/Program-termination/PL-I/program-termination-1.pli
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
STOP; /* terminates the entire program */
|
||||
/* PL/I does any required cleanup, such as closing files. */
|
||||
1
Task/Program-termination/PL-I/program-termination-2.pli
Normal file
1
Task/Program-termination/PL-I/program-termination-2.pli
Normal file
|
|
@ -0,0 +1 @@
|
|||
STOP THREAD (tiger); /* terminates only thread "tiger". */
|
||||
3
Task/Program-termination/PL-I/program-termination-3.pli
Normal file
3
Task/Program-termination/PL-I/program-termination-3.pli
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
SIGNAL FINISH; /* terminates the entire program. */
|
||||
/* PL/I does any required cleanup, */
|
||||
/* such as closing files. */
|
||||
1
Task/Program-termination/Perl-6/program-termination.pl6
Normal file
1
Task/Program-termination/Perl-6/program-termination.pl6
Normal file
|
|
@ -0,0 +1 @@
|
|||
if $problem { exit $error-code }
|
||||
6
Task/Program-termination/Perl/program-termination.pl
Normal file
6
Task/Program-termination/Perl/program-termination.pl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if ($problem) {
|
||||
exit integerErrorCode;
|
||||
# conventionally, error code 0 is the code for "OK"
|
||||
# (you can also omit the argument in this case)
|
||||
# while anything else is an actual problem
|
||||
}
|
||||
2
Task/Program-termination/PicoLisp/program-termination.l
Normal file
2
Task/Program-termination/PicoLisp/program-termination.l
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(push '*Bye '(prinl "Goodbye world!"))
|
||||
(bye)
|
||||
3
Task/Program-termination/Pop11/program-termination.pop11
Normal file
3
Task/Program-termination/Pop11/program-termination.pop11
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if condition then
|
||||
sysexit();
|
||||
endif;
|
||||
|
|
@ -0,0 +1 @@
|
|||
condition {stop} if
|
||||
|
|
@ -0,0 +1 @@
|
|||
condition {quit} if
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
if (somecondition) {
|
||||
exit
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
halt.
|
||||
|
|
@ -0,0 +1 @@
|
|||
abort.
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
If problem = 1
|
||||
End
|
||||
EndIf
|
||||
3
Task/Program-termination/Python/program-termination-1.py
Normal file
3
Task/Program-termination/Python/program-termination-1.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import sys
|
||||
if problem:
|
||||
sys.exit(1)
|
||||
3
Task/Program-termination/Python/program-termination-2.py
Normal file
3
Task/Program-termination/Python/program-termination-2.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
import os
|
||||
if problem:
|
||||
os.abort()
|
||||
1
Task/Program-termination/R/program-termination.r
Normal file
1
Task/Program-termination/R/program-termination.r
Normal file
|
|
@ -0,0 +1 @@
|
|||
if(problem) q(status=10)
|
||||
|
|
@ -0,0 +1 @@
|
|||
if error? try [6 / 0] [quit]
|
||||
|
|
@ -0,0 +1 @@
|
|||
if error? try [dangerous-operation] [quit/return -12]
|
||||
|
|
@ -0,0 +1 @@
|
|||
if error? try [something-silly] [q/return -12]
|
||||
|
|
@ -0,0 +1 @@
|
|||
view layout [button "stopme" [halt]]
|
||||
29
Task/Program-termination/REXX/program-termination.rexx
Normal file
29
Task/Program-termination/REXX/program-termination.rexx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
/*REXX program showing five ways to perform a REXX program termination. */
|
||||
|
||||
/*─────1st way────────────────────────────────────────────────────────*/
|
||||
exit
|
||||
|
||||
|
||||
/*─────2nd way────────────────────────────────────────────────────────*/
|
||||
exit (expression) /*Note: the "expression" doen't need parenthesis*/
|
||||
/*"expression" is any REXX expression. */
|
||||
|
||||
|
||||
/*─────3rd way────────────────────────────────────────────────────────*/
|
||||
return /*which returns to this program's invoker. If */
|
||||
/*this is the main body (and not a subroutine), */
|
||||
/*the REXX interpreter terminates the program. */
|
||||
|
||||
|
||||
/*─────4th way────────────────────────────────────────────────────────*/
|
||||
return (expression) /* [See the note above concerning parenthesis.] */
|
||||
|
||||
|
||||
/*─────5th way────────────────────────────────────────────────────────*/
|
||||
/*control*/
|
||||
/* │ */ /*if there is no EXIT and program control "falls */
|
||||
/* │ */ /*through" to the "bottom" (end) of the program, */
|
||||
/* │ */ /*an EXIT is simulated and the program is */
|
||||
/* │ */ /*terminated. */
|
||||
/* ↓ */
|
||||
/* e-o-f */ /* e-o-f = end-of-file. */
|
||||
1
Task/Program-termination/Retro/program-termination.retro
Normal file
1
Task/Program-termination/Retro/program-termination.retro
Normal file
|
|
@ -0,0 +1 @@
|
|||
problem? [ bye ] ifTrue
|
||||
3
Task/Program-termination/Ruby/program-termination-1.rb
Normal file
3
Task/Program-termination/Ruby/program-termination-1.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if problem
|
||||
exit(1)
|
||||
end
|
||||
3
Task/Program-termination/Ruby/program-termination-2.rb
Normal file
3
Task/Program-termination/Ruby/program-termination-2.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if problem
|
||||
abort # equivalent to exit(1)
|
||||
end
|
||||
1
Task/Program-termination/SNOBOL4/program-termination.sno
Normal file
1
Task/Program-termination/SNOBOL4/program-termination.sno
Normal file
|
|
@ -0,0 +1 @@
|
|||
&code = condition errlevel :s(end)
|
||||
2
Task/Program-termination/Scheme/program-termination-1.ss
Normal file
2
Task/Program-termination/Scheme/program-termination-1.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(if problem
|
||||
(exit)) ; exit successfully
|
||||
2
Task/Program-termination/Scheme/program-termination-2.ss
Normal file
2
Task/Program-termination/Scheme/program-termination-2.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(if problem
|
||||
(exit #f)) ; exit unsuccessfully
|
||||
2
Task/Program-termination/Scheme/program-termination-3.ss
Normal file
2
Task/Program-termination/Scheme/program-termination-3.ss
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
(if problem
|
||||
(exit some-value)) ; converts "some-value" into an appropriate exit code for your system
|
||||
9
Task/Program-termination/Seed7/program-termination.seed7
Normal file
9
Task/Program-termination/Seed7/program-termination.seed7
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const proc: main is func
|
||||
begin
|
||||
# whatever logic is required in your main procedure
|
||||
if some_condition then
|
||||
exit(PROGRAM);
|
||||
end if;
|
||||
end func;
|
||||
1
Task/Program-termination/Slate/program-termination.slate
Normal file
1
Task/Program-termination/Slate/program-termination.slate
Normal file
|
|
@ -0,0 +1 @@
|
|||
problem ifTrue: [exit: 1].
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
if problem then
|
||||
OS.Process.exit OS.Process.failure
|
||||
(* valid status codes include OS.Process.success and OS.Process.failure *)
|
||||
else
|
||||
()
|
||||
|
|
@ -0,0 +1 @@
|
|||
:Stop
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
Prgm
|
||||
...
|
||||
Stop
|
||||
...
|
||||
EndPrgm
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
$$ MODE TUSCRIPT
|
||||
IF (condition==1) STOP
|
||||
-> execution stops and message:
|
||||
IF (condition==2) ERROR/STOP "condition ",condition, " Execution STOP "
|
||||
6
Task/Program-termination/Tcl/program-termination-1.tcl
Normal file
6
Task/Program-termination/Tcl/program-termination-1.tcl
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
if {$problem} {
|
||||
# Print a “friendly” message...
|
||||
puts stderr "some problem occurred"
|
||||
# Indicate to the caller of the program that there was a problem
|
||||
exit 1
|
||||
}
|
||||
3
Task/Program-termination/Tcl/program-termination-2.tcl
Normal file
3
Task/Program-termination/Tcl/program-termination-2.tcl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
if {$problem} {
|
||||
error "some problem occurred"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue