Re: Dereferencing array elements with AllegroCL - how?

Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> Mon, 25 Aug 2003 21:00:49 -0600
Newsgroups gmane.lisp.uffi.general
Message-ID <[email protected]>
Edi Weitz wrote:
>   CL-USER(2): (uffi:deref-array (uffi:allocate-foreign-object :int 4) :int 2)
>   Error: slot name 2 can't be used for type
>          #S(FOREIGN-FUNCTIONS::SIZED-FTYPE-PRIM :KIND :INT :WIDTH 4
>                                                 :OFFSET 0 :ALIGN 4)
>     [condition type: SIMPLE-ERROR]
> 
> Is that not the right way to create an array and then dereference one
> of its elements? It works with CMUCL, LW, SBCL so I thought I was on
> the right track.

I think this same issue came up on another you asked about. I haven't
tested it for this example, but in general, you must pass an array
type to deref-array. You can look for examples in tests/arrays.lisp.

So, 
(uffi:deref-array (uffi:allocate-foreign-object :int 4) 
    '(:array :int) 2)
should work

--
Kevin Rosenberg
kevin-HJRc7zDS/[email protected]