Re: Dereferencing array elements with AllegroCL - how?
Edi Weitz <[email protected]> 26 Aug 2003 12:38:55 +0200
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 25 Aug 2003 21:00:49 -0600, Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> wrote: > 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. Really? Oh my, my memory.... :( > 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 Yes, RTFM... :) I think I'm bitten by this because it is kind of counter-intuitive, or rather redunant, to me. The operator is DEREF-ARRAY, so it should be clear that the type is an array. Wouldn't it suffice to provide the type of the array's elements? Anyway, just nitpicking. Thanks, Edi.