As 1, but output is redirected to a newly created file ;; NB: with-output-to-file is an optional procedure in R5RS (let ((hello0 (lambda () (display "Hello world") (newline)))) (with-output-to-file "helloworldoutputfile" hello0)) Example 4: As 2, but with explicit file open and port close to send output to file (let ((hello1 (lambda (p) (display "Hello world" p) (newline p))) (output-port (open-output-file "helloworldoutputfile"))) (hello1 output-port) (close-output-port output-port)) Example 5: As 2, but with using call-with-output-file to send output to a file. (let ((hello1 (lambda (p) (display "Hello world" p) (newline p)))) (call-with-output-file "helloworldoutputfile" hello1)) Similar procedures are provided for input. R5RS Scheme provides the predicates input-port? and output-port?. For character input and output, write-char, read-char, peek-char and char-ready? are provided. For writing and reading Scheme expressions, Scheme provides read and write. On a read operation, the result returned is the end-of-file object if the input port has reached the end of the file, and this can be tested using the predicate eof-object?. In addition to the standard, SRFI 28 defines a basic formatting procedure resembling Common Lisp's format function, after which it is named. Redefinition of standard procedures In Scheme, procedures are bound to variables. At R5RS the language standard formally mandated that programs may change the variable bindings of built-in procedures, effectively redefining them. (R5RS "Language changes") For example, one may extend + to accept strings as well as numbers by redefining it: (set! + (let ((original+ +)) (lambda args (apply (if (or (null? args) (string? (car args))) string-append original+) args)))) (+ 1 2 3) ===> 6 (+ "1" "2" "3") ===> "123" In R6RS every binding, including the standard ones, belongs to some library, and all exported bindings are immutable. (R6RS sec 7.1) Because of this, redefinition of standard procedures by mutation is forbidden. Instead, it is possible to import a different procedure under the name of a standard one, which in effect is similar to redefinition. Nomenclature and naming conventions In Standard Scheme, procedures that convert from one datatype to another contain the character string "->" in their name, predicates end with a "?", and procedures that change the value of already-allocated data end with a "!". These conventions are often followed by Scheme programmers. In formal contexts such as Scheme standards, the word "procedure" is used in preference to "function" to refer to a lambda expression or primitive procedure. In normal usage, the words "procedure" and "function" are