> Thank you very much for the clear and detailed explanation.  It
> certainly makes sense, although it does seem to have some unfortuante
> implications for the abstract design of fast programs in Lisp as
> compared to C/C++.  


Are you sure?  One of the big benefits of specialized arrays is that
when you declare a variable to reference a type that is a specialized
array the compiler knows the type of elements of the array when they
are referenced and, in the case of numeric operations, can choose 
specialized inline operations instead of calling generic ones.

With an array of structs (assuming you've declared types for the slots),
the compiler will know the return value of the structures accessor
functions and will be able to choose fast arithmetic operations based
on that.  Essentially, the only speed hit you're going to take is the
generic array ref for the array of structs case.  It will certainly run
slower--some quick experiments indicate around 2.5 times as slow.  
But 2.5 times very fast (as CMUCL is with double-floats in 
well-declared code) is still fast. 

Also, don't forget to declare the structure accessors inline. :)

Gabe Garza


Reply via email to