<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Dec 2, 2011, at 7:08 PM, Joshua TAYLOR wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>On Fri, Dec 2, 2011 at 8:56 PM, Alexander Repenning<br><<a href="mailto:ralex@cs.colorado.edu">ralex@cs.colorado.edu</a>> wrote:<br><blockquote type="cite">Using Mark Kantrowitz old but very handy infix we noticed some peculiar<br></blockquote><blockquote type="cite">pattern of errors where very basic expressions do not correctly convert<br></blockquote><blockquote type="cite">infix expressions into prefix ones. The version I just tried was this<br></blockquote><blockquote type="cite">one: <a href="http://www.cliki.net/infix">http://www.cliki.net/infix</a><br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">in => pre, red for incorrect<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">"a + 1" => (+ A 1)<br></blockquote><blockquote type="cite">"s + 1" => S+1<br></blockquote><blockquote type="cite">"s - 1" => S-1<br></blockquote><blockquote type="cite">"s * 1" => (* S 1)<br></blockquote><blockquote type="cite">"a + 1.5" => (+ A 1.5)<br></blockquote><blockquote type="cite">"s + 1.5" => (+ S 1.5)<br></blockquote><blockquote type="cite">"s + s" => (+ S S)<br></blockquote><blockquote type="cite">"s + 1 + 1" => (+ S+1 1)<br></blockquote><blockquote type="cite">"s + 1e1" => (+ S 10.0)<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Can somebody see a pattern here? AFAIK, the combination of the one letter<br></blockquote><blockquote type="cite">variables names that are characters D, E, F, L, or S followed by "+" or "-"<br></blockquote><blockquote type="cite">and then followed by an int does not work.<br></blockquote><br>Didn't look into the code, but those letters are special…<br><br>CL-USER 15 > (list 1.0d+0 1.0d-0<br> 1.0e+10 1.0e-10<br> 1.0f+0 1.0f-0<br> 1.0l+0 1.0f-0<br> 1.0s+0 1.0s-0)<br>(1.0D0 1.0D0 1.0E10 1.0E-10 1.0 1.0 1.0D0 1.0 1.0S0 1.0S0)<br><br>//JT<br><br>-- <br>Joshua Taylor, <a href="http://www.cs.rpi.edu/~tayloj/">http://www.cs.rpi.edu/~tayloj/</a><br></div></blockquote><br></div><div>Nice! </div><div><br></div><div>Yes, it does appear to be a genuine bug which confuses simple expressions such as "e + 1" with floating point literals. Bad floating point literal parsing going on here:</div><div><br></div><div>1) floating point numbers representations require the exponent marker to be preceded by at least a digit</div><div>2) do not allow spaces between the exponent marker, the exponent sign and exponent digits.</div><div><br></div><div>I found this function in infix.lisp which appears to be the culprit:</div><div><br></div><div><div>(defun fancy-number-format-p (left operator stream) </div><div> (when (and (symbolp left)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (find operator '(+ -) :test #'same-operator-p))</div><div> (let* ((name (symbol-name left))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (length (length name)))</div><div> (when (and (valid-numberp (subseq name 0 (1- length)))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> ;; Exponent, Single, Double, Float, or Long</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (find (subseq name (1- length))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> '("e" "s" "d" "f" "l")</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> :test #'string-equal))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(read-token stream)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(let ((right (peek-token stream)))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (cond ((integerp right)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> ;; it is one of the fancy numbers, so return it</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (read-token stream)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (let ((*readtable* *normal-readtable*))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (read-from-string (format nil "~A~A~A" </div><div><span class="Apple-tab-span" style="white-space:pre"> </span> left operator right))))</div><div><span class="Apple-tab-span" style="white-space:pre"> </span>(t</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> ;; it isn't one of the fancy numbers, so unread the token</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> (push operator *peeked-token*)</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> ;; and return nil</div><div><span class="Apple-tab-span" style="white-space:pre"> </span> nil)))))))</div></div><div><br></div><div>Just making it return nil will fix the conversation of expression such a "e + 1" to be (+ e 1) but of course will also ruin the capability to recognize real float literals. Does anybody have the energy to fix this? Time to go to bed...</div><div><br></div><div>Still surprised this bug has not surfaced before.</div><div><br></div><div>Alex</div><div><br></div><br><div>
<span class="Apple-style-span" style="font-size: 12px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">Prof. Alexander Repenning</font></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px">University of Colorado</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Computer Science Department</p><p style="margin: 0.0px 0.0px 0.0px 0.0px">Boulder, CO 80309-430</p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><br class="khtml-block-placeholder"></p><p style="margin: 0.0px 0.0px 0.0px 0.0px"><font face="Helvetica" size="3" style="font: 12.0px Helvetica">vCard: <a href="http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf">http://www.cs.colorado.edu/~ralex/AlexanderRepenning.vcf</a></font></p><br class="Apple-interchange-newline"></span></span></span>
</div>
<br></body></html>