Memory allocation: Difference between revisions

Content added Content deleted
(→‎C++: Added content)
(dynamic-extent declaration for allocation in CL)
Line 257: Line 257:
}
}
</lang>
</lang>

=={{header|Common Lisp}}==

Objects are typically automatically allocated and deallocated in Common Lisp. However, the <code>[http://www.lispworks.com/documentation/HyperSpec/Body/d_dynami.htm dynamic-extent]</code> declaration can be used to inform the compiler that the values a variable assumes can be stack-allocated.

{{works with|LispWorks}}

This behavior can be observed with the (not good for actual use) code:

<lang lisp>(defun show-allocation ()
(let ((a (cons 1 2))
(b (cons 1 2)))
(declare (dynamic-extent b))
(list a b)))</lang>

<lang lisp>(show-allocation)</lang>

produces

((1 . 2) #<unknown object, header / pointer: 7FFFFFFC /21B3BF09 21B3BF09>)


=={{header|E}}==
=={{header|E}}==