Solved: Re: [plt-scheme] problem with arity?

From: Mike (mikee at mikee.ath.cx)
Date: Wed May 31 20:10:42 EDT 2006

On Wed, 31 May 2006, Mike might have said:

> This must be my problem, but I don't see it.  I'm trying my hand
> at creating an extension interface to sqlite. I have the extension
> working now I'm trying to allow one of the routines to allow for
> errors. My intent is the scheme code could look like
> 
> (define db (sqlite:open "howard"))
> (sqlite:do db "drop table geek")	; this could cause an error and abort
> (sqlite:do db "drop table geek" 'error)	; same as above
> (sqlite:do db "drop table geek" 'warn)	; throw a warning and continue
> (sqlite:do db "drop table geek" 'ignore)	; ignore any errors
> 

<snip>

> static Scheme_Object *sch_dbdo(int argc, Scheme_Object **argv)
> {
>     DB *dbo;
>     sqlite3 *db;
>     sqlite3_stmt *stmt;
>     char *msg;
>     const char **data, **name;
>     const char *sql;
>     Scheme_Object *so;
>     int rc, ncol, ignore;
> 
>     /* check the arguments */
>     if(SCHEME_TYPE(argv[0]) != dbtype) {
>         scheme_wrong_type("sqlite:close", dbtypestr, 0, argc, argv);
>     }
>     if(!SCHEME_CHAR_STRINGP(argv[1])) {
>         scheme_wrong_type("sqlite:query", "string", 1, argc, argv);
>     }
>     ignore = 0;
>     if(argc == 2) {
-----------------^
For possible three arguments, this should be a 3 for argc and indexed as argv[2].

>         if(SCHEME_SYMBOLP(argv[2])) {
>             if(SCHEME_SYMBOLP(argv[2]) && !strcmp(SCHEME_SYM_VAL(argv[2]), "warn")) {
>                 ignore = 1;
>             } else if(SCHEME_SYMBOLP(argv[2]) && !strcmp(SCHEME_SYM_VAL(argv[2]), "error")) {
>                 ignore = 2;
>             } else {
>                 scheme_signal_error("sqlite:do: invalid keyword, must be 'warn or 'error if present\n");
>             }
>         } else {
>             scheme_wrong_type("sqlite:query", "symbol (optional: 'warn, 'error)", 2, argc, argv);
>         }
>     }
> 
>     /* intialize */
>     so = scheme_false;
> 
> ....
> }
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 


Posted on the users mailing list.