cl, lispworks question and mysql
Hello lispers!
I’m a newbie to Lisp and I have some questions, some concerning
Common Lisp in general, some to Lispworks.
As an exercise in learning Lisp and finding out what Lispworks’
implementation of CL is, I have written this code
http://www.obrezan.com/lisp/mysql.lisp
That’s a simple native mysql driver, that is it accesses to mysql
via the mysql client/server protocol. So called “a thing in itself”
that needs no third-party libraries (i.e. mysqllib), no ffi calls,
no even asdf (a formidable beast to me), but which actually works
and connects to the mysql server, send queries and get results back.
Questions:
1. How in Lispworks can I test if the socket stream was closed
on the other side? For example, the mysql server drops the connection
and I want to be aware of that fact.
2. To signal errors I use, as I got it, a simple-error error type.
Should I make up a special kind of error, say mysql-error?
Or simple-errors are ok?
3. Signaling errors and go into the debug-repl after it is an easy
part, but how do I handle errors in “production” code, that say
if I have access to the database in an web server code and there
is an error? I don’t want to stop my program in the debug-repl,
instead I need to catch that situation and spit, say to the web
browser, “oops, no database for today” and happily continue my
program. Use handle-case and handle-bind functions for that?
Can someone point me at some actual/sample code of such error
handling?
4. I coded the sha1 algorithm in generic CL. Lispworks have
functions that works in int32 – a lot of such functions. Should
I use them for speed/other benefits?
5. When I load that file into Lispworks’ IDE it asks me if I want
to create the mysql package, it doesn’t see my defpackage construct.
To suppress this “ai” behavior of the IDE at new loading of
mysql.lisp, how should I place my defpackage construct?
Into eval-then?
Thanks.
Best,
Art