Overview
| Artifact ID: | 344d4d41fa563f64db8cf7a12e8abdd612106b79 |
|---|---|
| Ticket: | 1733117fffffffffffffffffffffffffffffffff
auto_path changes and avail package cacheing issues |
| User & Date: | dgp on 2007-06-09 00:35:57 |
Changes
- icomment:
Logged In: YES user_id=80530 Originator: NO since I'm short on time, here's what I had to say on this in the chat: dgpre 1733117 my intent is to follow up in detail in the Tracker... [12:02]dgpbut briefly the answer is "not a bug" [12:03]kbkHmm, "not a bug" perhaps but at least surprising. [12:04]dgpprobably the most surprising thing... [12:04]dgp...is that [package require $p $requirement] does *not* make any guarantee to provide the latest version available [12:05]dgpit only promises to satisfy the requirements passed in as arguments [12:05]dgpIf some documentation somewhere says otherwise, then *that* is a bug [12:06]kbkHmmm. OK so far. Would an explicit requirement of the version that was on the new auto_path have found it? [12:06]dgpso, if an app really, really, really won't be satisfies with anything other than the very latest available, they'll have to use the lower level [package] subcommands to accomplish that for themselves [12:06]dgpI think all the tools are there. [12:06]kbk(That militates in favour of aku's practice of advancing patch levels in tcllib modules with every bugfix) [12:08]dgpif the modified auto_path makes findable a new version of a package... [12:08]dgpthat was not findable before... [12:08]dgp...then a requirement that is only satisfied by that new version, and was not satisfied by the older ones available [12:08]dgpwill find the new one, yes. [12:10]kbkok, I'm almost satisfied... although "latest available version that satisfies requirements" would make a lot of sense. [12:10]kbkOtherwise, consider an app that does [package require foo 1.0; package require bar 1.0] [12:11]kbkwhere (properly unknown to the app writer), foo does [package require grill 1.1] and bar does [package require grill 1.2]. [12:11]dgpWithout thinking it fully through, I think a custom [package unknown] handler can do this [12:17]dgpso quickly, how a cusom [package unknown] can solve the posed problem.... [12:17]dgpstart with [::tclPkgUnknown] which searches according to the value of ::auto_path... [12:18]dgpaugment it with a variable trace on ::auto_path that calls [package forget] when ::auto_path is written to. [12:18]dgpthen register this modified package finder with [package unknown] [12:18]dgpand voila, your app has the feature requested. jenglish-- I think all you need is a way to say "scan this directory for available packages _now_". [12:21]jenglish([lappend auto_path ...] just says "scan this directory for packages the next time somebody asks for a package you don't already know about", which is error-prone and order-dependent) [12:22]dgp[lappend auto_path ...; eval [package unknown] Tcl [package provide Tcl]] [12:22]dgpThat's not 100%, but it works with [tclPkgUnknown] [12:23]dgpcan't be 100% because a cusom [package unknown] handler is free to provide anything that satisfies requirements even if that means ignoring later available versions. [12:24]jenglishwait, I thought the package [package unknown] handler was only responsible for providing ifneeded scripts - not for providing the packages themselves. [12:25]dgp[package unknown] is for finding packages. [12:25]dgpwhen [package require] determines it can't satisfy requirement it knows about. [12:25]dgpThe default [package unknown], [tclPkgUnknown] goes searching for every version of every package it can find. [12:26]dgp...but other custom ones don't have to do that. [12:26]dgpThey get passed the package and requirements being sought. [12:26]jenglishSo the contract for [package unknown] handlers is: either provide the package, or register an ifneeded script that will provide the package? [12:26]dgpand are free to search less broadly with the aim to satisfy the stated requirement. [12:26]dgpFor example, the Tcl Module [package unknown] routine [12:27]dgpno [package unknown] never [package provide]s a package [12:27]dgp(assuming proper, nonabusive, usage) jenglishTFM says: "For example, if [the package-unknown handler] is 'foo bar' [...] then Tcl will execute the command 'foo bar test 2.4' *to load the package*" (emphasis mine) [12:32]dgpthat would probably be better rephrased. [12:32]dgpthe task for [foo bar test 2.4] to accomplish is to run at least one [package ifneeded foo $x] command [12:32]dgpwhere [package vsatisfies 2.4 $x] is true [12:33]jenglishRelated: calling [package forget] when auto_path changes might not be a good idea -- you don't want to forget previous [package provide]s, just the [package ifneeded]s. [12:33]dgpor to run no [package ifneeded] command at all, in the cases where no satisfaction can be had. [12:33]dgpyou would pass the package name to [package forget] [12:34]dgpthere are details to get right, you are correct. [12:34]dgpI think all the tools are available to accomplish that. [12:35]dgpwhen I get back to full time, perhaps I can offer a complet example Leaving this open since there's doc improvement likely to be useful.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"