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

From: Jens Axel Søgaard (jensaxel at soegaard.net)
Date: Wed Apr 13 16:31:37 EDT 2005

nishad at ptolemy.tlg.uci.edu wrote:

> In mzscheme v209, when I say 
> (require
>  (lib "schemeql.ss" "schemeql")
>  (lib "pregexp.ss" "mzlib")
>  (lib "string.ss" "srfi" "13")
>  (lib "list.ss" "srfi" "1"))
> it replies with
> repl-1:1:0: require: duplicate import identifier at: delete in: 

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: 
> (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 driver.
>         (require "odbc.ss"
>                  "exception.ss"
>                  (lib "list.ss") ;; remove
>                  )
> 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?  

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 ···)

require-spec is one of
   (prefix prefix-identifier module-name)
   (all-except module-name identifier ···)
   (prefix-all-except prefix-identifier module-name identifier ···)
   (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 ···)
form imports all identifiers from the named module, except for the
listed identifiers. The (prefix-all-except prefix-identifier
module-name identifier ···) 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.

Jens Axel Søgaard

Posted on the users mailing list.