From: Hemang L. <hl...@ci...> - 2008-12-11 14:06:33
|
Jan Nijtmans wrote: > 2008/12/11 Hemang Lavana <hl...@ci...>: > >> It's not as simple as doing "package provide" twice when tcl modules are >> involved. This is how our developers initially started out to support >> multiple cases for our packages. They had multiple "package provide" >> statements in their library to support FooBar, foobar and fooBar. However, >> when we started creating tcl modules for these packages, the "package >> provide" trick would no longer work. >> > > Here we are talking about packages implemented in C, not Tcl > modules, which has a lot of additional handling. Anyway, I'm very > interested to hear what the problem was, but I am confident > that for the situation we are talking about here, it doesn't apply. > I was talking in the context of original TIP. Let me elaborate on our problem. We have a package FooBar and we would like to support 3 styles of package names: FooBar (original name), fooBar (camelcase) and foobar (lowercase). Our pkgIndex.tcl file for this pkg was written as follows: # Begin pkgIndex.tcl set pkg_version 1.1 foreach pkg_name {FooBar fooBar foobar} { package ifneeded $pkg_name $pkg_version " source foobar-file1.tcl source foobar-file2.tcl #... package provide $pkg_name $pkg_version " } # End pkgIndex.tcl Some developers have also used the following style instead: package ifneeded foobar $pkg_version " package require FooBar $pkg_version ;# bug here, need to specify -exact option package provide foobar $pkg_version " The pkgIndex.tcl file and the foobar-*.tcl files were distributed to the users and they could load the pkg with one of the 3 pkg names. We started using tcl modules since it makes it easier to deploy -- only single file is required to be given to the user. However, for such packages, we have to create 3 tcl modules files: FooBar-1.1.tm, fooBar-1.1.tm and foobar-1.1.tm and ask the users to install all the 3 TM files. Having multiple "package provide" stmts in a single TM file doesn't work: rtp-lds-016:73> pwd /auto/wshlavana/ats5.0-main/lib/tcl8/8.4 rtp-lds-016:74> ls FooBar-1.1.tm rtp-lds-016:75> tclsh % package require foobar can't find package foobar % package require FooBar 1.1 % exit rtp-lds-016:76> cat FooBar-1.1.tm package require Tcl namespace eval foobar {} proc ::foobar::print {args} { puts "FooBar 1.1: $args" } package provide FooBar 1.1 package provide foobar 1.1 rtp-lds-016:77> If package names are made case-insensitive, then it resolves all these issues. Given that the original TIP did not pass due to backward compatibility concerns, I am proposing an alternate solution to let the developers decide whether their package name should be case-sensitive or not. > Anyway, thanks for your remarks. Your proposal might > be a good solution, but it's too late for Tcl 8.6. > It may be late for 8.6 but if we agree upon one approach, then there can be feature parity between core tcl and ActiveTcl versions. Thanks, Hemang. |