| Allegro CL version 8.0 Moderately revised from 7.0. | ||||||||||
Arguments: (var type &rest etc) &rest body
Allocate an object of type type and bind it to var while evaluating body. The body is evaluated inside a lexical binding of var. The var is bound to a foreign object allocated in a way that depends on the compile-time circumstances. The object will be of allocation type :foreign for the purposes of accessing it with fslot-value and associated functions. If the body is compiled under suitable circumstances (dynamic-extent declarations are trusted), then the object is allocated on the stack. The object will disappear after control leaves body thus the program must not maintain any pointers to the object past this point.
The allocation argument defaults to
:foreign, and can be one of :c,
:aligned, :lisp,
:lisp-short, :foreign, or
:foreign-static-gc. Note that if allocation is
:c or :aligned, it is not
stack-allocated, but instead is allocated and deallocated at the
appropriate places within the form.
Currently, if this form is evaluated by the interpreter, or is compiled under circumstances that don't trust dynamic-extent declarations, the object will be allocated as a :foreign object, which means it will be in the lisp heap.
This may not be what you want since you may need to allocate an object that doesn't move during garbage collection.
In situations where the allocation style is critical to an application, the compiled code may need to be inspected or disassembled to verify how the foreign object is allocated. A run-time check is also possible with excl::stack-allocated-p.
Multiple bindings can be done with with-stack-fobjects.
See ftype.htm for information on foreign types in Allegro CL and foreign-functions.htm for general information on foreign functions in Allegro CL.
Copyright (c) 1998-2008, Franz Inc. Oakland, CA., USA. All rights reserved.
This page has had moderate revisions compared to the 7.0 page.
Created 2007.4.30.
| Allegro CL version 8.0 Moderately revised from 7.0. | ||||||||||