<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Dec 14, 2017 at 5:49 PM, Pierpaolo Bernardi <span dir="ltr"><<a href="mailto:olopierpa@gmail.com" target="_blank">olopierpa@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Spec is not explicit, and currently different implementations do<br>
different things.<br>
<br> (let ((*print-circle* t)<br>        (name "q"))<br>
    (format nil "~A ~A" name name))      ==>  ?<br></blockquote><div><br></div><div>It may be true that implementations do different things, but IMO the standard permits only one result.  #n= notion aught not be produced.  See the first paragraph of the dictionary page for *print-circle*: </div></div><br></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">    Controls the attempt to detect circularity and sharing in an </span><a rel="DEFINITION" href="http://www.lispworks.com/documentation/HyperSpec/Body/26_glo_o.htm#object" style="font-family:"Times New Roman";font-size:medium"><i>object</i></a><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"> being printed.</span><br></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">FORMAT is not a function that prints an <u>object</u>.  Instead, i</span><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">t interprets a format control.  </span><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">A call to FORMAT may print zero objects or any number of objects.</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">The functions that are specified to print an object are WRITE, PRINT, PRINC, PRIN1, and PPRINT (which might all be conceptually defined to make the obvious call to WRITE on that object, although this is not required), their mumble-TO-STRING versions, and PPRINT-LINEAR, PPRINT-FILL, and PPRINT-TABULAR.  The printer is recursive, but is the outermost entry to one of these functions that defines the boundary for circularity detection.  (PRINT-OBJECT might be included in this set, but it is not necessary since it ought only be called dynamically inside one of the others.)</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">~A, ~S, ~W and various others (e.g. when a numeric format control is given a non-number) act as if they make the obvious call to WRITE.  </span><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">I maintain that the ANS is firm that the following results (here in sbcl) are correct and required.  *PRINT-CIRCLE* is true:</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">* (let ((g "a")) (format nil "~a ~a" g g))</font></div><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">"a a"</font></div><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">* (let ((g "a")) (format nil "~a" (list g g)))</font></div><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">"(#1=a #1#)"</font></div><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">* (let ((g "a")) (format nil "~{~a ~}" (list g g)))</font></div><div class="gmail_extra"><font color="#000000" face="Times New Roman" size="3">"a a "</font></div></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">The first two examples are clear from the above argument.  The third follows from the description of ~{, which specifies that it behaves like a recursive format control, and therefore also does not itself "print an object".</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium">So while the ANS is not ambiguous here, this issue can be hard to understand and a clarification could indeed be useful.  However, it can only be a clarification, neither a change nor resolution of an ambiguity. It bears repetition that the X3J13 goal for the ANS was a <u>specification</u>.  Ease of understanding was of course desirable, but a very secondary consideration.  There are a great many tangled or distant interrelated passages; one needs be intimately familiar with the entire document even to rememberwhere to look for the other end of a tangle.  Also, it is inconceivable to me that someone not already familiar with some Lisp dialect could learn CL from the ANS.</span></div><div class="gmail_extra"><span style="color:rgb(0,0,0);font-family:"Times New Roman";font-size:medium"><br></span></div></div>