exit(3scm)
π exit(3scm)
okay so real quick β this page lives in the Scheme Programmer's Manual, and it's genuinely the most main-character procedure ever because it's the one that ends the whole show. no encore, no curtain call, just β¨goneβ¨.
π NAME
exit β exit the program. that's it. that's the whole vibe. bye bestie π
π LIBRARY
import it however your Scheme likes, all three paths lead to the same slay:
(import (rnrs)) ;R6RS
(import (rnrs programs)) ;R6RS
(import (scheme process-context)) ;R7RS
β¨ SYNOPSIS
(exit)
(exit obj)
πΈ DESCRIPTION
so what it does: it exits the running program and tells the operating system an exit value. like, it communicates. it reports back. very communicative of it honestly π«Ά.
if you don't hand it an argument, exit should tell the OS that the program exited normally. (good ending π). if you do pass an argument, exit should translate that argument into an appropriate exit value for the operating system β it figures out how to say what you meant in OS-speak.
here's the lil gotcha π: if obj is #f, the exit is assumed to be abnormal. not the good ending. the messy ending π.
- R7RS β runs all outstanding
dynamic-windafter procedures, terminates the running program, and communicates an exit value to the operating system. and in R7RS,(exit #t)is literally the same thing as(exit). same energy, same result β¨.
the exit procedure must not signal an exception or return to its continuation. like, ever. that's non-negotiable. and because it's got that whole "run the handlers first" requirement, it is not just the operating system's exit procedure β it's got extra responsibilities, it's doing the most, and it's doing it for you π
.
π οΈ IMPLEMENTATION NOTES
most implementations just return obj immediately to the operating system if it's a number between 0 and 255. no notes, straightforward, iconic.
- GNU Guile, Chez Scheme β these implementations run the
dynamic-windafter procedures. good for them honestly π.
π« RETURN VALUES
this procedure does not return.
like. at all. it's not coming back. don't wait up π.
π« EXAMPLES
(exit) ;no return
see that comment? ;no return. it wasn't kidding.
π§ APPLICATION USAGE
ngl, this procedure should be avoided in libraries. like, not your place, bestie π. applications mainly use it to return errors to the operating system β either signalling to the shell that the command has failed to execute correctly, or signalling to the init system that the service has failed. drama, but make it diagnostic π.
π COMPATIBILITY
R6RS does not explicitly say that the dynamic-wind exit handlers should run. some implementations run them and some do not. so like... it's giving "it depends" and honestly that's just how it is π¦.
π₯ ERRORS
this procedure can raise exceptions with the following condition types:
&assertion(R6RS) β the wrong number of arguments was passed. you gave it too much or not enough. it noticed. π€- R7RS β the assertions described above are errors. implementations may signal an error, extend the procedure's domain of definition to include such arguments, or fail catastrophically. yes, catastrophically. that's the actual word. no cap ππ₯.
π SEE ALSO
emergency-exit(3scm)exit(3)dynamic-wind(3scm)
β STANDARDS
R6RS, R7RS π
π¦ HISTORY
this procedure first appeared in R6RS and later appeared in R7RS as well. and fun fact: MacLISP had a quit function with similar functionality. so this vibe is, like, historically certified πβ¨.
π«Ά AUTHORS
this page is part of the scheme-manpages project. it includes materials from the RnRS documents. more information can be found at https://github.com/schemedoc/manpages/.
okay that's the whole page!! and yeah, dated 2022-03-26, straight out of the Scheme Programmer's Manual β exit(3scm), our forever icon, taken from the manpage source and living rent free in your terminal ππ·β¨
π¦ where this page comes from
- nixpkgs unstable: scheme-manpages 0-unstable-2024-02-11
- π the page's license: MIT
- Copyright (c) 2022 Gwen Weinholt
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms