[Openmcl-devel] two portability issues

Gary Byers gb at clozure.com
Sat Dec 20 12:37:13 PST 2014


On 12/20/2014 10:53:40 AM, Rainer Joswig wrote:
> 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…
> 

Please read and try to understand section 3.2.3.1.1, then think about  
whether your understanding of the issues here is correct.  I strongly  
suspect that it isn't.

> 
> ** 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.

Does it return the same result (perhaps more slowly) if the FIXNUM  
declaration is retained and the OPTIMIZE declaration is changed to  
something like (SAFETY 3) (SPEED 0) ?

Does the (non-portable, LispWorks-specific) (FIXNUM-SAFETY 0)  
declaration affect the result returned in LispWorks  ?

> 
> 
> Regards,
> 
> Rainer Joswig
> 
> 
> 
> 
> 
> 

------quoted attachment------
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel
> 




More information about the Openmcl-devel mailing list