Updated 2012-07-11 11:00:19 by RLE

Problem: Sometimes you don't want to require a particular package; you just need a particular interface, and maybe many packages provide it.

package require operates on packages not interfaces, so what's a good way to deal with alternative implementations of an interface? (for example, C-coded and Tcl-coded versions of the same commands, or perhaps implementations competing on other grounds?)

Main goal is to get complicated logic out of the user application. A single declarative command should be sufficient. I need version x of the foo interface

Option 1 - a wrapper knows about multiple candidates

Write a common wrapper package that knows what packages provide a common interface. Have it supply configuration command to control choosing. Then the user just requires the wrapper package.

Wrapper can also translate any difference in the interfaces -- DB front end?

Option 2 - alternatives know about each other

Index scripts / provide scripts of alternatives might be written to recgonize avilability of an alternative and less desirable one could refrain from calling package ifneeded. This is really a type of variant management, as it will be most effective if the two alternatives are variants of a single version of a single package.

Option 3 - Accrue knowledge of interface compatibility on-the-fly. Not hard-coded into any one package.

3a:: an extension that will accept registration of claims of support for named, versioned interface, with mechanisms for selecting between alternatives.

3b:: new subcommands of package instead of a separate extension.