Re: array initialisation
- From: pjb@xxxxxxxxxxxxxxxxx (Pascal J. Bourguignon)
- Date: Wed, 30 Apr 2008 09:57:29 +0200
nicolas.edel@xxxxxxxxx writes:
Suppose I define a class foo
CL-USER> (defclass foo () ())
#<STANDARD-CLASS FOO>
Now I define a function that creates an array of instances of class
'foo.
CL-USER> (defun bar (x)
(make-array x :element-type 'foo :initial-element
nil))
; in: LAMBDA NIL
; (MAKE-ARRAY X :ELEMENT-TYPE 'FOO :INITIAL-ELEMENT NIL)
;
; caught STYLE-WARNING:
; NIL is not a FOO.
;
; compilation unit finished
; caught 1 STYLE-WARNING condition
BAR
I get a warning (that I could ignore) since NIL is indeed not an
instance of the FOO class.
How to create such an array with an initial value that allows me to
test whether one of its element has already been instanciated or not ?
Like Thomas says, or:
(defun bar (x)
(make-array x :element-type '(or null foo) :initial-element nil))
which should not make much difference when foo is not a 'basic' type
like fixnum, character or double-float...
--
__Pascal Bourguignon__
.
- References:
- array initialisation
- From: nicolas . edel
- array initialisation
- Prev by Date: Re: found .emacs, but doesnt work running lisp
- Next by Date: Re: Iteration in lisp
- Previous by thread: Re: array initialisation
- Next by thread: Cells: using def-c-echo or def-slot-change-handler and unbound-variable condition
- Index(es):
Relevant Pages
|
|