Discussion of Common Lisp
- Posts: 11
- Joined: Tue Nov 25, 2008 6:37 am
- Location: Gliwice, Poland
Had a hard day coding in CL and looking for basic knowledge on this language.
Let's assume I'll define a structure:
Code: Select all
(slot-1 0 :type fixnum)
(slot-2 0.0d0 :type double-float))
It's a new type. How can I make an array of elements of that type? I've tried (make-array (list 5) :element-type 'my-Str), but all I got was an array of type T.
- Posts: 613
- Joined: Sun Jun 29, 2008 4:02 am
- Location: Warsaw, Poland
The purpose of array types is to allow implementation to use specialized memory layout for the array. The specification allows the type to be upgraded to most specific such type (see http://www.lispworks.com/documentation/ ... upgr_1.htm
). In the case of custom types no specialized layout is possible in general (custom type redefinition is allowed at any time), so the array is just an array of pointers, that is, of type T.
- Posts: 41
- Joined: Tue Jul 01, 2008 5:11 am
- Location: Lexington, MA
Just don't specify an element type. Then the array elements can hold any Lisp object.
(It's better not to use the word "pointer" when talking about Lisp, I've found.)