LispWorks User Guide and Reference Manual > 27 The COMMON-LISP Package

NextPrevUpTopContentsIndex

make-array

Function
Summary

Creates and returns a new array which, in addition to the standard functionality, can be a weak array or statically allocated.

Package

common-lisp

Signature

make-array dimensions &key element-type initial-element initial-contents adjustable fill-pointer displaced-to displaced-index-offset weak allocation => new-array

Arguments

weak

A generalized boolean.

allocation

A fixnum, or one of nil , :new , :static , :old , or :long-lived .

single-thread

A generalized boolean.

Description

The standard definition of make-array is extended to accept the keyword arguments :weak and :allocation .

If weak is non-nil, then displaced-to must be nil and if element-type is supplied it must have upgraded-array-element-type t , otherwise an error is signalled. That is, you cannot make a weak array which is displaced or has array-element-type other than t . When weak is non-nil, it makes new-array weak.

If weak is nil , then make-array behaves in the standard way, and new-array is not weak. The value weak defaults to nil .

See set-array-weak for a description of weak arrays.

The possible values for allocation have the following meanings:

:new

Allocate the array normally.

nil

Same meaning as :new . This is the default value.

:static

Allocate the array in a static segment.

:long-lived

Allocate the array assuming it is going to be long-lived.

:old

Same meaning as :long-lived

A fixnum n

Allocate the array in generation n .

Arrays (including strings) that are passed by address to foreign functions must be static, and so must should be created with :allocation :static .

Allocation with :old or :long-lived is useful when you know that the array will be long-lived, because your program will avoid the overhead of promoting it to the older generations.

If single-thread is true then the system knows that new-array will always be accessed in a single thread context. That makes some operations faster, in particular vector-pop and vector-push . The default value of single-thread is nil .

See also

array-weak-p
set-array-single-thread-p
set-array-weak


LispWorks User Guide and Reference Manual - 22 Dec 2009

NextPrevUpTopContentsIndex