Hi Berlin,

Thanks for writing this library. Database bindings are very useful  
and important.

On 12-Feb-07, at 12:49 AM, Berlin Brown wrote:

> ! License: See http://factor.sf.net/license.txt for BSD license.

Please change this URL to http://factorcode.org/license.txt.

> ! ##to include## "mysql" "libmySQL.dll" "stdcall" add-library

You can use something like this:

"mysql" {
     { [ windows? ] [ "libmySQL.dll" "stdcall" ] }
     { [ macosx? ] [ "libmysqlclient.14.dylib" "cdecl" ] }
     { [ unix? ] [ "libmysqlclient.so.14" "cdecl" ] }
} cond add-library

> TYPEDEF: void* MYSQL

You define this type but never use it anywhere.
>
> : init-mysql ( -- conn )
>       f mysql_init ;

Please use soft tabs, 4 characters per tab.

> : (mysql-row>seq) ( object n -- seq )
>       #! Convert the input fetched row into a seq of
>       #! of string values.
>       V{ } clone -rot
>       [               
>               swap char*-nth
>               over push
>       ] each-with  ;

Instead, do

: (mysql-row>seq) ( object n -- seq )
     [ swap char*-nth ] map-with ;


> : (mysql-result>seq) ( seq -- seq )
>       my-conn get (mysql-row) dup f = [
>               drop
>       ] [             
>               my-conn get (mysql-num-cols) (mysql-row>seq)
>               over push
>               (mysql-result>seq)
>       ] if ;

dup f = [ A ] [ B ] if

is equivalent to

dup [ B ] [ A ] if


> : (mysql-close) ( mysql-connection -- )
>       mysql-connection-mysqlconn mysql_close ;

As a matter of style, we don't define a word named (foo) unless  
there's a word named foo, too, and (foo) happens to be used in the  
implementation of (foo) while not being useful in its own right.

> : with-mysql-catch ( host user password db port quot -- )
>     [ with-mysql ] catch [ "Caught: " write print ] when* ;

I don't think this word is necessary.
>
> "localhost" "factoruser" "mysqlfactor" "factordb_development" 0 [
>       get-drop-table mysql-command drop
>       get-create-table mysql-command drop
>       get-update-table mysql-command drop
>       get-delete-table mysql-command drop
>       
>       ! Insert multiple records
>       10 [
>               get-insert-table mysql-command 2drop
>       ] each
>               
>       "select * from discussion_forum order by created_on" mysql-query drop
>       mysql-result>seq mysql-print-table
>
> ] with-mysql-catch

You can get rid of the with-mysql-catch here. When you run the file,  
the listener will print the error if there is one.

Once you make the above corrections, you should make a libs/mysql  
module with the proper structure.

Your next step would be to either set up a public darcs repository  
(if you have a web server) or otherwise use 'darcs send' to mail me a  
patch.

Cheers

Slava


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to