Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Bug in pkg_mkIndex and namespaces

Closed / Fixed218451ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 26 years ago
Descriptionplain2000-10-26 01:00:33
OriginalBugID: 573 Bug
Version: 8.0p2
SubmitDate: '1998-05-21'
LastModified: '1999-08-15'
Severity: LOW
Status: Released
Submitter: hershey
ChangedBy: hobbs
OS: Solaris
OSVersion: 2.6
Machine: NA
FixedDate: '1999-08-15'
FixedInVersion: 8.2
ClosedDate: '2000-10-25'


Hi folks, try this...

1. Save this to test.tcl:

package provide x 1.0
namespace eval A {
        namespace export b
        proc b {} {}
}
namespace import A::b

2. In tclsh8.0 do this...
% source test.tcl
% exit

3. So far so good. Now restart tclsh and try this
% pkg_mkIndex . test.tcl
error while loading or sourcing test.tcl: can't import command
"b":
already exists
%

Any idea why? seems like it should be OK to me: The file defines
two
commands, "A::b" and "b"

What I'm trying to do is hide (well, "obfuscate" is probably more
accurate I guess) all the implementation details of a package in a

namespace, and then import a few of the procs into the global
namespace.
I can think of some work arounds, but basically they involve
writing a
proc in the global namespace that uses variables from the
package's
namespace, and it would be tidier if I could just use 'variable
whatever' when I wanted to do this.

Details: tcl 8.0p2, Solaris 2.6
Thanks.
---------------------------------------------------------------
David Houlder                             Phone: (06) 249 0668
Centre for Resource and Environmental Studies  (+61 6 249 0668)
The Australian National University         Fax: +61 6 249 0757



This works in 8.2, although maybe not as desired.  Before 8.0.5,
there was a -verbose switch created to prevent the error, but
the indexing wouln't work, because of the use of namespace import
without the -force switch in the pkg_mkIndex command.  Adding this
(which was done before 8.2) will make it work.  However, in this
automation, the procs are still recognized in their qualified
state.  So ::A::b will be put in the pkgIndex.tcl file, not 'b'.
The user may want to edit the pkgIndex.tcl file by hand in this
case. 
-- 08/15/1999 hobbs
welch Closed ticket [218451ffff]. [History diff]2000-10-26 08:22:16
dgp Ticket [218451ffff]: 3 changes [History diff]2001-04-16 20:36:45
Log in (anonymous is fine) to add a comment.