Re: array initialisation
- From: nicolas.edel@xxxxxxxxx
- Date: Tue, 29 Apr 2008 06:28:17 -0700 (PDT)
On Apr 29, 3:14 pm, Edi Weitz <spamt...@xxxxxxxxxx> wrote:
On Tue, 29 Apr 2008 05:36:44 -0700 (PDT), nicolas.e...@xxxxxxxxx wrote:
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 ?
How about '(or null foo) as the element type?
Beside the fact this works, this is elegant ;)
The more I learn Lisp, the more I find it consistent and powerfull.
Thank you.
-Nicolas
.
- References:
- array initialisation
- From: nicolas . edel
- Re: array initialisation
- From: Edi Weitz
- array initialisation
- Prev by Date: Re: CLforJava
- Next by Date: Re: Cells: using def-c-echo or def-slot-change-handler and unbound-variable condition
- Previous by thread: Re: array initialisation
- Next by thread: Re: array initialisation
- Index(es):
Relevant Pages
|
|