From: <dg...@ni...> - 2008-12-11 23:11:32
|
I'm about 30 messages buried in e-mail so forgive me if someone else has already come forward with the same solution. First, make [package] as it is now into an ensemble in the conventional way, redirecting subcommands to the corresponding [tcl::package::*] command. ([package provide] -> [tcl::package::provide]). Next define this proc: proc ::tcl::package::Ifneeded {name v script} { # omit redirect of the "no script argument" case # do what we do now ifneeded $name $v $script # For all lowercase package names, we're done set lcname [string tolower $name] if {$name eq $lcname} {return} # package names with more "interesting" case get # entered into the database a second time in # all lowercase form, using chaining to pull in # the real package name: set lcscript [list package require $name $v-$v] append lcscript \n[list package provide $lcname $v] ifneeded $lcname $v $lcscript } Then change the ensemble redirection so that [package ifneeded] routes to [::tcl::package::Ifneeded]. Now no changes need to be made to any existing package. Any package that doesn't have an all lowercase name will automatically make itself available in both original and all lowercase naming variants. Doing this with ensemble redirections means the ability to completely restore the legacy mode is possible. We can ponder whether a command to set "compat mode" for that is worthwhile, but with less urgency since even if we don't do it we leave the tools in place at script level for those users who must have it to make it so for themselves. No begging and pleading and hoping for package authors to get their act together (a proven losing strategy), and at the same time, no destructive refusal to use the names those authors have asked to use. Simply the addition of a bridge. DGP |