newline(3scm)
π newline β write a newline to a port π
okay bestie, so this is newline from the Scheme Programmer's Manual, and it's lowkey one of the most iconic little procedures ever β it just... ends a line. that's it. that's the whole vibe. β¨
πΈ LIBRARY πΈ
import it from whichever flavour of Scheme you're living in, no judgement:
(import (rnrs)) ;R6RS
(import (rnrs io simple)) ;R6RS
(import (scheme r5rs)) ;R7RS
(import (scheme base)) ;R7RS
π SYNOPSIS π
(newline)
(newline textual-output-port)
π DESCRIPTION π
So it writes an end of line to textual-output-port, which defaults to whatever current-output-port(3scm) hands back. yes bestie, default port, it just knows. π«Ά
R6RS β this is literally equivalent to using write-char(3scm) to write #\linefeed to textual-output-port.
the port's transcoder eol-style decides which characters actually get written to the port. so like, the flavour of newline is not your call here, it's the transcoder's call. periodt.
also!! ports with their buffer-mode set to line will be flushed as a side-effect of calling this procedure. so you get a little flush for free, no cap. π¦
R7RS β exactly how a newline is produced, and which characters are used, differs from one operating system to another. so it's giving "trust the implementation" energy. π
β RETURN VALUES β
- R6RS β returns unspecified values.
- R7RS β returns an unspecified value.
(notice the singular vs plural, we keep the details exact around here π)
π EXAMPLES π
(display "Hello, world!")
(newline)
look at that. beautiful. iconic. hello world but on its own line. π₯
π§ APPLICATION USAGE π§
in R6RS programs this procedure may be used instead of \n in a string or instead of writing #\linefeed. very "we have options, pick your fave" of it.
in R7RS programs this procedure writes the characters that would have been selected for a newline by using a transcoder with native-eol-style(3scm) in R6RS. iykyk. π«
π COMPATIBILITY π
this procedure has had the same basic functionality since R2RS. she's a legacy icon, she's been doing this since forever. π
in R6RS implementations it's possible to control the eol-style. fancy.
π ERRORS π
this procedure can raise exceptions with the following condition types:
&assertion(R6RS) β the wrong number of arguments was passed or an argument was outside its domain. so like, don't do that bestie π- 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, fail catastrophically, that's the actual wording, we're not being dramatic for once π
π SEE ALSO π
π¦ STANDARDS π¦
R4RS, IEEE Scheme, R5RS, R6RS, R7RS β she's certified in literally all of them. ate. π
πΈ HISTORY πΈ
first appeared in R2RS. Scheme running on top of MacLisp has access to the same functionality through the terpri (TERminate PRInt line) function, which was also in LISP 1.5. deep lore, we love to see it. π§
π 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/.
and that's the whole page bestie, mwah π«Ά β this little masterpiece is from 2022-05-07, filed under newline(3scm), bestie-certified and ready to end your lines πβ¨
π¦ 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