<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I just looked a small benchmark someone wrote and tried to improve it.</div><div class=""><br class=""></div><div class="">The result is here:</div><div class=""><br class=""></div><div class=""><a href="https://gist.github.com/lispm/6066e1eeadf943910c47" class="">https://gist.github.com/lispm/6066e1eeadf943910c47</a></div><div class=""><br class=""></div><div class="">The corresponding data file is here:</div><div class=""><br class=""></div><div class=""><a href="https://raw.githubusercontent.com/logicchains/LPATHBench/master/agraph" class="">https://raw.githubusercontent.com/logicchains/LPATHBench/master/agraph</a></div><div class=""><br class=""></div><div class=""><b class="">There were two issues I saw with CCL:</b></div><div class=""><br class=""></div><div class="">** first issue:  DEFSTRUCT defined type at compile time unknown? **</div><div class=""><br class=""></div><div class="">There is a structure declaration ROUTE via a DEFSTRUCT.</div><div class=""><br class=""></div><div class="">I wanted to use the type ROUTE in a LOOP later in the function</div><div class=""><br class=""></div><div class=""><pre class="line-pre" style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 12px; margin-top: 0px; margin-bottom: 0px; width: 748px; color: rgb(51, 51, 51); line-height: 16px;"><div class="line" id="file-gistfile1-lisp-LC36" style="box-sizing: border-box;">(<span class="pl-st" style="box-sizing: border-box; color: rgb(167, 29, 93);">defun</span> <span class="pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">get-longest-path</span> (nodes node-id visited &aux (max <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>))
</div><div class="line" id="file-gistfile1-lisp-LC37" style="box-sizing: border-box;">  (declare (optimize (speed <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">3</span>) (space <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>) (debug <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>) (safety <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>) (compilation-speed <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>)
</div><div class="line" id="file-gistfile1-lisp-LC38" style="box-sizing: border-box;">           <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">#+lispworks</span> (fixnum-safety <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">0</span>))
</div><div class="line" id="file-gistfile1-lisp-LC39" style="box-sizing: border-box;">           (fixnum max))
</div><div class="line" id="file-gistfile1-lisp-LC40" style="box-sizing: border-box;">  (<span class="pl-s3" style="box-sizing: border-box; color: rgb(0, 134, 179);">setf</span> (svref visited node-id) <span class="pl-s3" style="box-sizing: border-box; color: rgb(0, 134, 179);">t</span>)
</div><div class="line" id="file-gistfile1-lisp-LC41" style="box-sizing: border-box;">  (<span class="pl-s3" style="box-sizing: border-box; color: rgb(0, 134, 179);">setf</span> max (<span class="pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">loop</span> for neighbour of-type route in (svref nodes node-id)     ; <—  declaration
</div><div class="line" id="file-gistfile1-lisp-LC42" style="box-sizing: border-box;">                  unless (svref visited (route-dest neighbour))
</div><div class="line" id="file-gistfile1-lisp-LC43" style="box-sizing: border-box;">                  maximize (+ (the fixnum (route-cost neighbour))
</div><div class="line" id="file-gistfile1-lisp-LC44" style="box-sizing: border-box;">                              (the fixnum (get-longest-path nodes
</div><div class="line" id="file-gistfile1-lisp-LC45" style="box-sizing: border-box;">                                                            (route-dest neighbour)
</div><div class="line" id="file-gistfile1-lisp-LC46" style="box-sizing: border-box;">                                                            visited)))
</div><div class="line" id="file-gistfile1-lisp-LC47" style="box-sizing: border-box;">                  <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">#+lispworks</span> fixnum))
</div><div class="line" id="file-gistfile1-lisp-LC48" style="box-sizing: border-box;">  (<span class="pl-s3" style="box-sizing: border-box; color: rgb(0, 134, 179);">setf</span> (svref visited node-id) <span class="pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">nil</span>)
</div><div class="line" id="file-gistfile1-lisp-LC49" style="box-sizing: border-box;">  max)
</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">The CCL compiler did not know about the type ROUTE, so I had to use EVAL-WHEN around the structure definition. Shouldn’t the compiler recognize the type at compile time? The ANSI CL documentation for DEFSTRUCT indicates that…</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class="">** second issue:  LOOP clause MAXIMIZE**</div></div><div class=""><br class=""></div><div class=""><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class="">in above function there is a clause  MAXIMIZE … FIXNUM .</div></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class="">In CCL (and several other implementations, with the exception of LispWorks) this causes that a wrong result (a negative number) is computed. Without the FIXNUM declaration the result is correct.</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class="">Regards,</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class="">Rainer Joswig</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 14px; line-height: normal; white-space: normal;" class=""><br class=""></div><div class=""><br class=""></div></pre></div></body></html>