Re: array initialization: dimension list not constant



In article <muxmzf6k8tv.fsf@xxxxxxxxxxxxxxxxxx>,
Didier Verna <didier@xxxxxxxxxxxxx> wrote:

Just to be sure ...


in something like (make-array (* width height) ...)

CMUCL might complain that the dimension list is not constant, so it cannot
open-code the array creation routine.


This has an impact on the performance of the array creation, but not on
subsequent operations onto the array, right ?

If the compiler knows the size of the array, it may be able to optimize
some array bounds checks, perhaps even warn you about exceeding them.
For instance, it could conceivably reject this code:

(let ((new-array (make-array 3)))
(setf (aref new-array 4) 'x)
new-array)

--
Barry Margolin, barmar@xxxxxxxxxxxx
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
.



Relevant Pages

  • Re: Array constructor or literal
    ... Douglas Crockford wrote: ... consistent. ... I'm sure there are very *specific* cases where it makes a difference, but we're talking about 9 bytes saved per array creation. ...
    (comp.lang.javascript)
  • Re: Newbie PHP question operators
    ... Michael Fesser wrote: ... > causes overhead and a performance hit due to the array creation and the ... have to add the value into your array creation. ...
    (comp.lang.php)
  • Re: array creation as reference, or always copied?
    ... Or are the vast majority of ... >examples of array creation in the manual (and most PHP code) ... As other people have pointed out Array() is not a function. ...
    (comp.lang.php)
  • Re: Confusing Arraylist BinarySearch problem
    ... When I run this code directly after the array creation: ... For some reason ... The above code returns the proper index value. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Can Windows CL compilers be as fast as CMUCL ?
    ... (loop for i fixnum below (the fixnum (length array)) ... int i,j,k; ... So C++ code is about 15 times faster than LispWorks version. ... CMUCL code is as fast as C++ version. ...
    (comp.lang.lisp)