Writes
datumto
out, normally in such a way that instances of core datatypes can be read back in. If
outhas a handler associated to it via
port-write-handler, then the handler is called. Otherwise, the
default printeris used (in
writemode), as configured by various parameters.
See The Printer for more information about the default printer. In particular, note that write may require memory proportional to the depth of the value being printed, due to the initial cycle check.
Examples:
Displays
datumto
out, similar to
write, but usually in such a way that byte- and character-based datatypes are written as raw bytes or characters. If
outhas a handler associated to it via
port-display-handler, then the handler is called. Otherwise, the
default printeris used (in
displaymode), as configured by various parameters.
See The Printer for more information about the default printer. In particular, note that display may require memory proportional to the depth of the value being printed, due to the initial cycle check.
The optional quote-depth argument adjusts printing when the print-as-expression parameter is set to #t. In that case, quote-depth specifies the starting quote depth for printing datum.
The rationale for providing print is that display and write both have specific output conventions, and those conventions restrict the ways that an environment can change the behavior of display and write procedures. No output conventions should be assumed for print, so that environments are free to modify the actual output generated by print in any way.
Added in version 6.1.1.8 of package base.
The same as
(display datum out)followed by
(newline out), which is similar to
printlnin Pascal or Java.
The same as
(print datum out quote-depth)followed by
(newline out).
The println function is not equivalent to println in other languages, because println uses printing conventions that are closer to write than to display. For a closer analog to println in other languages, use displayln.
Added in version 6.1.1.8 of package base.
Prints formatted output to out, where form is a string that is printed directly, except for special formatting escapes:
~n or ~% prints a newline character (which is equivalent to \n in a literal format string)
~a or ~A displays the next argument among the vs
~s or ~S writes the next argument among the vs
~v or ~V prints the next argument among the vs
~.‹c› where ‹c› is a, A, s, S, v, or V: truncates default-handler display, write, or print output to (error-print-width) characters, using ... as the last three characters if the untruncated output would be longer
~e or ~E outputs the next argument among the vs using the current error value conversion handler (see error-value->string-handler) and current error printing width
~c or ~C write-chars the next argument in vs; if the next argument is not a character, the exn:fail:contract exception is raised
~b or ~B prints the next argument among the vs in binary; if the next argument is not an exact number, the exn:fail:contract exception is raised
~o or ~O prints the next argument among the vs in octal; if the next argument is not an exact number, the exn:fail:contract exception is raised
~x or ~X prints the next argument among the vs in hexadecimal; if the next argument is not an exact number, the exn:fail:contract exception is raised
~~ prints a tilde.
~‹w›, where ‹w› is a whitespace character (see char-whitespace?), skips characters in form until a non-whitespace character is encountered or until a second end-of-line is encountered (whichever happens first). On all platforms, an end-of-line can be #\return, #\newline, or #\return followed immediately by #\newline.
The form string must not contain any ~ that is not one of the above escapes, otherwise the exn:fail:contract exception is raised. When the format string requires more vs than are supplied, the exn:fail:contract exception is raised. Similarly, when more vs are supplied than are used by the format string, the exn:fail:contract exception is raised.
Example:
(3 4) as a string is "(3 4)".
Formats to a string. The result is the same as
Example:
> (format "~a as a string is ~s.\n" '(3 4) "(3 4)")"(3 4) as a string is \"(3 4)\".\n"
A
parameterthat controls pair printing. If the value is true, then pairs print using
{and
}instead of
(and
). The default is
#f.
A
parameterthat controls pair printing. If the value is true, then mutable pairs print using
{and
}instead of
(and
). The default is
#t.
A
parameterthat controls printing data with sharing; defaults to
#f. See
The Printerfor more information.
A
parameterthat controls printing structure values in vector or
prefabform; defaults to
#t. See
The Printerfor more information. This parameter has no effect on the printing of structures that have a custom-write procedure (see
prop:custom-write).
A
parameterthat controls printing of booleans. When the parameter’s value is true,
#tand
#fprint as
#trueand
#false, otherwise they print as
#tand
#f. The default is
#f.
A
parameterthat controls printing of two-element lists that start with
quote,
'quasiquote,
'unquote,
'unquote-splicing,
'syntax,
'quasisyntax,
'unsyntax, or
'unsyntax-splicing; defaults to
#f. See
Printing Pairs and Listsfor more information.
A
parameterthat controls printing of
syntax objects. Up to
widthcharacters are used to show the datum form of a syntax object within
#<syntax...
>(after the
syntax object’s source location, if any), where
...is used as the last three characters if the printed form would otherwise be longer than
widthcharacters. A value of
0for
widthmeans that the datum is not shown at all.
A
parameterthat contains a recommendation for the number of columns that should be used for printing values via
print. May or may not be respected by
print- the current default handler for
printdoes not. It is expected that REPLs that use some form of pretty-printing for values respect this parameter.
Added in version 8.0.0.13 of package base.
A
parameterthat is used when writing compiled code (see
Printing Compiled Code) that contains pathname literals, including source-location pathnames for procedure names. When the parameter’s value is a
path, paths that syntactically extend
pathare converted to relative paths; when the resulting compiled code is read, relative paths are converted back to complete paths using the
current-load-relative-directoryparameter (if it is not
#f; otherwise, the path is left relative). When the parameter’s value is
(cons rel-to-path base-path), then paths that syntactically extend
base-pathare converted as relative to
rel-to-path; the
rel-to-pathmust extend
base-path, in which case
'uppath elements (in the sense of
build-path) may be used to make a path relative to
rel-to-path.
Gets or sets the
port write handler,
port display handler, or
port print handlerfor
out. This handler is called to output to the port when
write,
display, or
print(respectively) is applied to the port. Each handler must accept two arguments: the value to be printed and the destination port. The handler’s return value is ignored.
A port print handler optionally accepts a third argument, which corresponds to the optional third argument to print; if a procedure given to port-print-handler does not accept a third argument, it is wrapped with a procedure that discards the optional third argument.
The default port display and write handlers print Racket expressions with Racket’s built-in printer (see The Printer). The default print handler calls the global port print handler (the value of the global-port-print-handler parameter); the default global port print handler is the same as the default write handler.
A global port print handler optionally accepts a third argument, which corresponds to the optional third argument to print. If a procedure given to global-port-print-handler does not accept a third argument, it is wrapped with a procedure that discards the optional third argument.
Added in version 8.8.0.6 of package base.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4