Tcl Source Code

View Ticket
Login
Ticket UUID: 1101678
Title: rewrite [pkg_mkIndex -lazy] to generate tclIndex file
Type: RFE Version: None
Submitter: vincentdarley Created on: 2005-01-13 14:48:58
Subsystem: 39. Package Manager Assigned To: dgp
Priority: 5 Medium Severity:
Status: Open Last Modified: 2005-01-26 00:59:38
Resolution: None Closed By: dgp
    Closed on: 2005-01-13 15:46:31
Description:
The attached script creates a package 'testpkg' which
provides two auto-loadable procs 'testpkg::one' and
'testpkg::two'.

If we execute 'testpkg::one', then do 'auto_reset' and
then try to execute 'testpkg::two', the latter is no
longer available -- the auto_index entry has been cleared.

Or, for example:

package require testpkg
# Now 'testpkg::one' and 'testpkg::two' are both available
# for auto-loading and execution
auto_reset
# Now both of those procs have been lost!
User Comments: dgp added on 2005-01-19 22:43:55:

data_type - 360894

Logged In: YES 
user_id=80530

interesting idea.  I'd need to think
about it and look over the code
implications, but I like it enough
to make it a Feature Request.

vincentdarley added on 2005-01-18 16:55:19:
Logged In: YES 
user_id=32170

I've added a comment to '-lazy' to suggest it not be used.

However, I still think there's a problem here, at least in
the documentation, and probably in limitations of
pkg_mkIndex.  The documentation says you should use
'pkg_mkIndex', and goes to some lengths to explain simple vs
complex packages, dependencies etc.

However, the end result is simply that 'pkg_mkIndex' works
well for a package composed of a single file (whether .dll
or .tcl), but anything more than that, given that -lazy is
buggy, requires one to manually created a tclIndex file and
then manually create a pkgIndex.tcl file (which has to add
$dir to the auto_path).

Surely pkg_mkIndex should do that for me.  In fact, why not
re-write the '-lazy' implementation to do just that:

-lazy will:

(i) build its list of source-able procs and load-able
commands as per normal.
(ii) Then it will write those things to a new tclIndex file
in the given directory (this is a new step).
(iii) Finally it will construct a pkgIndex.tcl file which
adds the relevant $dir to the auto_path.

In this way we would have something that actually _works_,
has no problems with 'auto_reset', and has the properties of
'-lazy' that we want (don't source every single script in a
multi-script package unless we actually need them).

vincentdarley added on 2005-01-14 18:23:56:
Logged In: YES 
user_id=32170

Can we at least document that pkg_mkIndex -lazy should not
be used so others don't fall into this trap.

Or, better yet, document what _should_ be used instead! 
This is not a theoretical problem, this report comes from
attempting to use the package tclAE which is part of
Daniel's BI distribution for MacOS X.

dgp added on 2005-01-13 22:46:31:
Logged In: YES 
user_id=80530

On this one, I'll agree that
there's a misfeature, but
there's no bug here.

The real misfeature is
[tclPkgSetup], and the
[pkg_mkIndex -lazy] that
creates it.  Don't use either.
They're broken by design
and not worth fixing.

If you want auto-loading
in your package, create
the appropriate tclIndex
file to make it happen.

vincentdarley added on 2005-01-13 21:52:25:
Logged In: YES 
user_id=32170

Note that bug 1101670 means that after auto_loading of all
of the procs provided by the given package, we will no
longer see this bug -- i.e. bug 1101670 is masking some
possible occurrences of this problem, at least for good
packages that place their code inside a namespace.

This is because 1101670 implies that procs in a namespace
will not be deleted.

A more general comment: the basic conflict seems to arise
because auto_reset assumes all auto_index entries can be
regenerated from tclIndex files, so it's ok to delete them,
but auto_index entries created by tclPkgSetup cannot be
recreated...

vincentdarley added on 2005-01-13 21:48:58:

File Added - 115691: runtest.tcl

Attachments: