User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:variables:star-print-circle-star [2017/05/01 21:00] (current)
Line 1: Line 1:
 +====== Variable *PRINT-CIRCLE* ======
 +
 +====Value Type====
 +a //​[[CL:​Glossary:​generalized boolean]]//​.
 +
 +====Initial Value====
 +//​[[CL:​Glossary:​false]]//​.
 +
 +====Description====
 +Controls the attempt to detect circularity and sharing in an //​[[CL:​Glossary:​object]]//​ being printed.
 +
 +If //​[[CL:​Glossary:​false]]//,​ the printing process merely proceeds by recursive descent without attempting to detect circularity and sharing.
 +
 +If //​[[CL:​Glossary:​true]]//,​ the printer will endeavor to detect cycles and sharing in the structure to be printed, and to use ''#​n=''​ and ''#​n#''​ syntax to indicate the circularities or shared components.
 +
 +If //​[[CL:​Glossary:​true]]//,​ a user-defined **[[CL:​Functions:​print-object]]** //​[[CL:​Glossary:​method]]//​ can print //​[[CL:​Glossary:​object|objects]]//​ to the supplied //​[[CL:​Glossary:​stream]]//​ using **[[CL:​Functions:​write]]**,​ **[[CL:​Functions:​prin1]]**,​ **[[CL:​Functions:​princ]]**,​ or **[[CL:​Functions:​format]]** and expect circularities and sharing to be detected and printed using the ''#​n#''​ syntax.
 +
 +If a user-defined **[[CL:​Functions:​print-object]]** //​[[CL:​Glossary:​method]]//​ prints to a //​[[CL:​Glossary:​stream]]//​ other than the one that was supplied, then circularity detection starts over for that //​[[CL:​Glossary:​stream]]//​.
 +
 +Note that implementations should not use ''#​n#''​ notation when the //​[[CL:​Glossary:​Lisp reader]]// would automatically assure sharing without it (//e.g.// as happens with //​[[CL:​Glossary:​interned]]//​ //​[[CL:​Glossary:​symbols]]//​).
 +
 +====Examples====
 +<​blockquote> ​
 +(let ((a (list 1 2 3)))
 +  ([[CL:​Macros:​setf]] (cdddr a) a) 
 +  (let ((*print-circle* t)) 
 +    (write a) 
 +    :done))
 +<​o>#​1=(1 2 3 . #​1#​)</​o>​
 +<​r>:​DONE </r>
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​write|Function WRITE]]**
 +
 +====Notes====
 +An attempt to print a circular structure with **[[CL:​Variables:​star-print-circle-star|*print-circle*]]** set to **[[CL:​Constant Variables:​nil]]** may lead to looping behavior and failure to terminate.
 +
 +\issue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:​X3J13-MAR-93} \issue{PRINT-CIRCLE-SHARED:​RESPECT-PRINT-CIRCLE} \issue{PRINT-CIRCLE-STRUCTURE:​USER-FUNCTIONS-WORK} \issue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:​X3J13-MAR-93} \issue{DEFSTRUCT-PRINT-FUNCTION-AGAIN:​X3J13-MAR-93}