[Openmcl-devel] two portability issues

Rainer Joswig joswig at lisp.de
Sat Dec 20 09:53:40 PST 2014


Hi,

I just looked a small benchmark someone wrote and tried to improve it.

The result is here:

https://gist.github.com/lispm/6066e1eeadf943910c47 <https://gist.github.com/lispm/6066e1eeadf943910c47>

The corresponding data file is here:

https://raw.githubusercontent.com/logicchains/LPATHBench/master/agraph

There were two issues I saw with CCL:

** first issue:  DEFSTRUCT defined type at compile time unknown? **

There is a structure declaration ROUTE via a DEFSTRUCT.

I wanted to use the type ROUTE in a LOOP later in the function

(defun get-longest-path (nodes node-id visited &aux (max 0))
  (declare (optimize (speed 3) (space 0) (debug 0) (safety 0) (compilation-speed 0)
           #+lispworks (fixnum-safety 0))
           (fixnum max))
  (setf (svref visited node-id) t)
  (setf max (loop for neighbour of-type route in (svref nodes node-id)     ; <—  declaration
                  unless (svref visited (route-dest neighbour))
                  maximize (+ (the fixnum (route-cost neighbour))
                              (the fixnum (get-longest-path nodes
                                                            (route-dest neighbour)
                                                            visited)))
                  #+lispworks fixnum))
  (setf (svref visited node-id) nil)
  max)


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…


** second issue:  LOOP clause MAXIMIZE**

in above function there is a clause  MAXIMIZE … FIXNUM .

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.


Regards,

Rainer Joswig





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clozure.com/pipermail/openmcl-devel/attachments/20141220/fb8cdc6c/attachment.htm>


More information about the Openmcl-devel mailing list