The Print module provides ways to print
objects. It also provides printing properties (depth,
circular, etc), and inspection of those properties.
print | [Method] |
Prints an object on a stream
Synopsis
print (object, stream, #key level, length, circle?, pretty?) => ()
Parameters
object An instance of <object>.stream An instance of <stream>.level:An instance of <integer-or-false-or-not-supplied>. Holds the maximum depth to which the user wants recursive printing to go. Defaults to$not-supplied.length:An instance of <integer-or-false-or-not-supplied>. Holds the maximum number of elements the user wants a sequence to be printed. This does not apply to some sequences, such as strings. Defaults to$not-supplied.circle?:An instance of <boolean-or-not-supplied>. Defines print behavior when printing a circular list Defaults to$not-supplied.pretty?:An instance of <boolean-or-not-supplied>. Whether the user wants pretty printing. Defaults to$not-supplied.
Return Values
None.
Description
Prints
objecttostreamaccording to the print request formed by the keyed arguments. A first call toprint-object. Though the inspection functions for querying the print request allow you to inspect any parameter of the print request,print-objectmethods should only need to callprint-length. All other aspects of the print request are handled byPPrintmodule (pretty-printing).
Levelcontrols how deep into a nested data structure to print. The value#findicates that there is no limit. The default,*default-level*, has no effect on recursive calls toprint-levelexplicitly, butlevelto 5, and while at a depth of 3, a recursive call specified alevelof 4, the recursive call would only descend 2 more levels, not 4.
Lengthcontrols how many elements of a sequence to print before printing ellipsis notation (...). The value#findicates that there is no limit. Theprint-lengthcontrol can be interpreted loosely by someprint-objectmethods to control how many elements of any kind of object to print; for example, the default<object>method might regardprint-lengthto determine how many slot-name/value pairs to print. The default,*default-length*, has no effect on recursive calls toprint-lengthexplicitly, but they may only decrease the value, never increase it.
Circle?indicates whether printing should check all subcomponent references to make sure the printing process does not infinitely recurse through a data structure. Circular printing also tags objects that occur more than once when they are first printed, and later occurrences are printed as a reference to the previously emitted tag. The default,*default-circle?*, has no effect on recursive calls toprint-circle?is already#t, then it remains#tthroughout all recursive calls. Ifprint-circle?is#f, then recursive calls to#t; however, when printing exits the dynamic scope of the call that changed the value to#t, the value reverts to#f. If the original call tocircle?as#f, and dynamically distinct recursive calls turn circular printing on and off, all output generated while circular printing was on shares the same tagging space; that is, if#1#is printed twice, once from each of two distinct recursive calls to#1#is guaranteed to signify the same\==object.
Pretty?indicates whether printing should attempt to insert line breaks and indentation to format objects according to how programmers tend to find it easier to read data. The default,*default-pretty?*, has no effect on recursive calls toprint-pretty?is already#t, then it remains#tthroughout all recursive calls. Ifprint-pretty?is#f, then recursive calls to#t; however, when printing exits the dynamic scope of the call that changed the value to#t, the value reverts to#f.
print-object | [Method] |
The default way to print objects
Synopsis
print-object (object, stream) => ()
Parameters
object An instance of <object>.stream An instance of <stream>.
Return Values
None.
Description
Users extend
print-objectfunction. Whenprint-object. Users should never callprint-objectdirectly.Provides the printed object representation for
print-objectmethods exist for instances of<object>,<character>,<string>,<list>,<vector>,<sequence>,<array>,<table>,<range>,<function>,<singleton>,<limited-integer>,<union>,<symbol>,<general-integer>,<integer>,<ratio>,<single-float>,<double-float>,<extended-float>,<class>, and for#tand#f.Users may choose to modify the printed representation in two ways: override the
print-objectmethod for that instance's type, or provide a printing function to the"%m"directive forformatorformat-out.
print-to-string | [Method] |
Creates a string that contains a printed object representation
Synopsis
print-to-string (object, #key level, length, circle?, pretty?) => (result)
Parameters
object An instance of <object>.level:An instance of <integer-or-false-or-not-supplied>. Holds the maximum depth to which the user wants recursive printing to go. Defaults to$not-supplied.length:An instance of <integer-or-false-or-not-supplied>. Holds the maximum number of elements the user wants a sequence to be printed. This does not apply to some sequences, such as strings. Defaults to$not-supplied.circle?:An instance of <boolean-or-not-supplied>. Defines print behavior when printing a circular list Defaults to$not-supplied.pretty?:An instance of <boolean-or-not-supplied>. Whether the user wants pretty printing. Defaults to$not-supplied.
Return Values
result An instance of <byte-string>.
Description
Calls
The above print functions use or set the
below exported variables to accomplish their work (#f
(the default value of all these variables) indicates there is
no bounds for the variable):
*default-level* | [Variable] |
Gives how far down recursively to print
Type
false-or(<integer>)Description
If a number is given,
#when it reached the level.
*default-length* | [Variable] |
How many elements to print of a sequence
Type
false-or(<integer>)Description
If a number is given,
...to indicate that it reached the maximum number of printable elements.
*default-circle?* | [Variable] |
What to do for circular lists
Type
<boolean>Description
If on, prints identical objects as, e.g.:
#1#
*default-pretty?* | [Variable] |
Formats outputted object
Type
<boolean>Description
If on, prints object indented with proper line breaks, according to the formatting specifications given to
pprint-logical-block.
The below functions give printing information on
<stream>s. It seems, however,
that these functions are neither used nor implemented, as they
all give #f or 0 as their response, no matter the
<stream>.
print-length | [Method] |
Always returns #fSynopsis
print-length (stream) => (length)
Parameters
stream An instance of <stream>.
Return Values
length An instance of false-or(<integer>).
Description
Returns the current value for the print request. See the
print-level | [Method] |
Always returns #fSynopsis
print-level (stream) => (level)
Parameters
stream An instance of <stream>.
Return Values
level An instance of false-or(<integer>).
Description
Returns the current value for the print request. See the
print-objectonly when the print level has not been exhausted.
print-depth | [Method] |
Always returns 0Synopsis
print-depth (stream) => (depth)
Parameters
stream An instance of <stream>.
Return Values
depth An instance of <integer>.
Description
Returns the current depth to which printing has descended into the object on which print was originally called.
print-objectonly when the print depth has not been exhausted.
print-pretty? | [Method] |
Always returns #fSynopsis
print-pretty? (stream) => (pretty?)
Parameters
stream An instance of <stream>.
Return Values
pretty? An instance of #f.
Description
Returns whether pretty printing is on. Users should have little use for this function (see the Section called PPrint Module).
print-circle? | [Method] |
Always returns #fSynopsis
print-circle? (stream) => (circle?)
Parameters
stream An instance of <stream>.
Return Values
circle? An instance of #f.
Description
Returns whether circular printing is on. Users should have little use for this function because