[Larceny-users] sqlite3 FFI
Felix Klock
felixluser at pnkfx.org
Sat May 31 10:07:07 EDT 2008
On May 30, 2008, at 10:56 PM, Peter Keller wrote:
> Hello,
>
> I have another question, if I may ask:
>
> in my sqlite3 library, I have this:
>
> (define-c-info (include<> "sqlite3.h")
> (const SQLITE_INTEGER int "SQLITE_INTEGER")
> (const SQLITE_FLOAT int "SQLITE_FLOAT")
> (const SQLITE_BLOB int "SQLITE_BLOB")
> (const SQLITE_TEXT int "SQLITE_TEXT"))
>
> and then later something like this:
>
> (define sqlite3-column
> (lambda (stmt colid)
> (case (sqlite3-column-type stmt colid)
> ((SQLITE_INTEGER)
> (sqlite3-column-int stmt colid))
> ((SQLITE_TEXT)
> (sqlite3-column-text stmt colid))
> (else
> 'oops)))) ;; <- obviously this is still test code!
>
> It looks like the SQLITE_INTEGER and SQLITE_TEXT in the sqlite3-column
> function are not available to me (as the code simply doesn't work and
> I get 'oops all the time) while in the library codes. If I replace
> them
> with the real constants 1 and 3 respectively, or use SQLITE_INTEGER
> and
> SQLITE_TEXT in a piece of code which imports the sqlite3 library, then
> sqlite3-column behaves properly.
>
> Any ideas?
Are you sure you mean to use Scheme's case special form in the above?
That is, is (sqlite3-column-type stmt colid) going to produce a
Symbol, or an Integer? If it produces a Symbol, then your case
expression might work. If it produces an Integer, then you will never
get anything other than 'oops back.
-Felix
More information about the Larceny-users
mailing list