[plt-scheme] SchemeQL and list.ss not on speaking terms?

From: nishad at ptolemy.tlg.uci.edu (nishad at ptolemy.tlg.uci.edu)
Date: Wed Apr 13 18:07:22 EDT 2005

Thank you so much, guys.  I'm embarrassed at not having read the
manual on require.  It (and provide, and the whole module system, in
fact) seems great, now that I actually look at it.

[I guess the error message was telling me exactly what the problem
was; but I found "...identifier at: delete in: ..." difficult to
parse.  I assume fonts or something would have made it clearer in
DrScheme.]

Right, so that fixed my name clash problem.  Unfortunately, I seem to
be having another--possibly similar--issue with SchemeQL.

I can run simple select queries just fine.  When I do an insert using
the form 

  (insert (table (val ...)))

that works fine, too.  However, when I use the form 

  (insert (table (col ...) (val ...)))

it complains:

> (schemeql-execute (insert dropme (a b) (42 "holita")))
reference to undefined identifier: rest
> (insert/cc dropme (a) (45))
reference to undefined identifier: rest

I've tried requiring mzlib's list.ss, as well as defining rest myself
as a synonym for cdr, but neither one works (I'm not sure if the
latter is what schemeql wants, anyway).

As I mentioned in my first message, there is already a (require (lib
"list.ss")) in schemeql/connection.ss, and I can't see any place where
rest might be excepted.  So what gives?

I'm sorry if these are terribly basic questions, but I've never really
explored PLT Scheme to this extent before.  Your help is enormously
appreciated.  Cheers!

nishad 

ps> While I'm asking naive questions, why do we have both list.ss in
mzlib as well as SRFI 1?  Why not have just one package comprising all
list functions?  It seems a bit strange to have 'first' from SRFI 1
and 'rest' from mzlib.


=?ISO-8859-1?Q?Jens_Axel_S=F8gaard?= wrote:
> 
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> 
> nishad at ptolemy.tlg.uci.edu wrote:
> 
> > In mzscheme v209, when I say=20
> >=20
> > (require
> >  (lib "schemeql.ss" "schemeql")
> >  (lib "pregexp.ss" "mzlib")
> >  (lib "string.ss" "srfi" "13")
> >  (lib "list.ss" "srfi" "1"))
> >=20
> > it replies with
> >=20
> > repl-1:1:0: require: duplicate import identifier at: delete in:=20
> 
> The problem is that the two libraries both export a binding
> with the name 'delete'.
> 
> There are several things you can do:
> 
> 1. Rename all bindings imported from one of the libraries
> ---------------------------------------------------------
> 
>    (require (prefix sql: (lib "schemeql.ss" "schemeql")))
>    (require (lib "list.ss" "srfi" "1"))
> 
> All names imported from schemesql is now prefixed with sql: .
> That is sql:delete is the binding exported from schemesql and
> delete is the one exported from srfi-1.
> 
> 
> 2. Rename only one the duplicate binding
> ----------------------------------------
> 
>    (require (all-except (lib "schemeql.ss" "schemeql") delete))
>    (require (rename (lib "schemeql.ss" "schemeql") sql:delete delete))
>    (require (lib "list.ss" "srfi" "1"))
> 
> The only renamed identifier is sql:delete all other bindings keep
> their name.
> 
> 
> 3. Import only one of the bindings
> ----------------------------------
> 
>    (require (lib "schemeql.ss" "schemeql"))
>    (require (all-except (lib "list.ss" "srfi" "1") delete))
> 
> The srfi-1 function delete is not needed, so we don't import it.
> 
> 
> > Looking around in the SchemeQL collection, I find this at the top of
> > connection.ss:=20
> >=20
> > (module connection mzscheme
> >         ;; if, and when, the need to use a different driver with
> >         ;; SchemeQL arises.  this require will have to be
> >         ;; modify to require the appropriate interface for such a drive=
> r.
> >         (require "odbc.ss"
> >                  "exception.ss"
> >                  (lib "list.ss") ;; remove
> >                  )
> >=20
> > Notice the "remove" comment for list.ss.  Is this causing the
> > "duplicate import identifier" message?  Should I simply follow the
> > author's advice and nuke that line? =20
> 
> That won't help. What's important is what the library provides.
> In general it is a bad idea to make changes in others libraries -
> it will lead to problems, when you update to the next version.
> 
> Search for require and provide in the HelpDesk to see what you can do.
> Here is the excerpt for require.
> 
> 
> The require form is used both to invoke a module at the top level,
> and to import syntax and variables into a module.
> 
> (require require-spec =B7=B7=B7)
> 
> require-spec is one of
>    module-name
>    (prefix prefix-identifier module-name)
>    (all-except module-name identifier =B7=B7=B7)
>    (prefix-all-except prefix-identifier module-name identifier =B7=B7=B7)=
> 
>    (rename module-name local-identifier exported-identifier)
> 
> The module-name form imports all exported identifiers from the named
> module. The (prefix prefix-identifier module-name) form imports all
> identifiers from the named module, but locally prefixes each identifier
> with prefix-identifier. The (all-except module-name identifier =B7=B7=B7)=
> 
> form imports all identifiers from the named module, except for the
> listed identifiers. The (prefix-all-except prefix-identifier
> module-name identifier =B7=B7=B7) form combines the prefix and all-except=
> 
> forms. Finally, the
> (rename module-name local-identifier exported-identifier) imports
> exported-identifier from module-name, binding it locally to identifier.
> 
> --=20
> Jens Axel S=F8gaard
> 
> 


-- 
"Things ain't been the same since the blues walked into town."

                                                -- Larry Love



Posted on the users mailing list.