Skip to content

Commit 7a0bb28

Browse files
committed
Improve &exit documentation.
Specify that exit status code has to be interpreted by calling process, and that LEAVE is prevented when using exit. Remark that &exit should be used to terminate abnormally only the main process, while exceptions should be used for other cases (e.g., methods). This does not remove the TODO item attached, but I believe there's not a better place to document exit since it is already documented with the usage of MAIN and the phasers.
1 parent b794a73 commit 7a0bb28

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

doc/Type/Any.pod6

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,14 @@ Defined as:
293293
294294
sub exit(Int() $status = 0)
295295
296-
Exits the current process with return code C<$status>.
296+
Exits the current process with return code C<$status> or zero if no value has been specified.
297+
The exit value (C<$status>), when different from zero, has to be opportunely evaluated from the
298+
process that catches it (e.g., a shell).
299+
300+
C<exit> does prevent the L<LEAVE|/phasers#LEAVE> phaser to be executed.
301+
302+
C<exit> should be used as last resort only to signal the parent process about an exit code different from zero,
303+
and should not be used to terminate exceptionally a method or a sub: use L<exceptions|/language/exceptions> instead.
297304
298305
=comment TODO maybe find a better place to document &exit
299306

0 commit comments

Comments
 (0)