Re: Package unloading
- From: Donald G Porter <dgp@xxxxxxxx>
- Date: Wed, 30 Jan 2008 11:31:40 -0500
Derek Fountain wrote:
What is the relationship between the file "foo.tcl" and the package
"mypackage" ?
foo.tcl is a file full of procs that make up the functionality of mypackage. It's source'ed via autoload/auto_index when a proc in it is needed.
Ah. That's the key. Auto-loading is the feature of the problem making
this difficult.
I'd encourage you to examine just what it is you think auto-loading is
doing for you. Most of the justifications for it I can imagine have
passed from the scene. Simplest answer, at least long term, might be
"Stop Doing That".
If you do need or want to keep auto-loading, then you'll need to actually delete commands in order to force the auto-loader to load
them over again. If your package follows recommended conventions, that
should be a simple matter of [namespace delete ::mypackage]. [*]
Yes, I'm doing my package loading in what I thought was the "standard" way, but maybe it's only standard to me because that's how I've always done it.
I would describe it as doing packages in the "Tcl 7 way" myself. It
works, but there's better choices now.
I think adding something like Brian's 'reload' to my package loading is going to be the best way.
proc reload {p args} {
# auto_reset ;# Only if your edits invalidate a tclIndex file
catch {namespace delete ::$p} ;# safety if unconventional
package forget $p
package require $p {*}$args
}
[*] There is a third way. If you want to have auto-loading as a feature, but don't want the burden of [namespace delete] during iterative development, you can implement auto-loading for yourself with stub-proc definitions of your commands. Not making use of [unknown] or auto* at all.
--
| Don Porter Mathematical and Computational Sciences Division |
| donald.porter@xxxxxxxx Information Technology Laboratory |
| http://math.nist.gov/~DPorter/ NIST |
|______________________________________________________________________|
.
- Follow-Ups:
- Re: Package unloading
- From: Derek Fountain
- Re: Package unloading
- References:
- Package unloading
- From: Derek Fountain
- Re: Package unloading
- From: Donald G Porter
- Re: Package unloading
- From: Derek Fountain
- Package unloading
- Prev by Date: Re: Missing bindings when running a Tk app from C
- Next by Date: Re: Why doesn't foreach return a value
- Previous by thread: Re: Package unloading
- Next by thread: Re: Package unloading
- Index(es):
Relevant Pages
|