package require searching module path in wrong order
Closed / Fixed86ceb4e2b63cfcee65abade0ed16c9ce846b4e30Created 13 years agoUpdated 13 years ago
Descriptionhtml2013-07-15 05:47:53
The tm documentation says that a module should be loaded from the module path by looking from the first in the list to the last. However I find that the opposite is happening. The problem can be demonstrated as so:
If I do:
::tcl::tm::path list
I get:
/usr/lib/tcltk/tcl8/site-tcl /usr/lib/tcltk/tcl8/8.0
/usr/lib/tcltk/tcl8/8.1 /usr/lib/tcltk/tcl8/8.2
/usr/lib/tcltk/tcl8/8.3 /usr/lib/tcltk/tcl8/8.4
/usr/lib/tcltk/tcl8/8.5 /usr/lib/tcltk/tcl8/8.6
/usr/lib/tcl8/site-tcl /usr/lib/tcl8/8.0
/usr/lib/tcl8/8.1 /usr/lib/tcl8/8.2
/usr/lib/tcl8/8.3 /usr/lib/tcl8/8.4
/usr/lib/tcl8/8.5 /usr/lib/tcl8/8.6
/usr/share/tcltk/tcl8/site-tcl /usr/share/tcltk/tcl8/8.0
/usr/share/tcltk/tcl8/8.1 /usr/share/tcltk/tcl8/8.2
/usr/share/tcltk/tcl8/8.3 /usr/share/tcltk/tcl8/8.4
/usr/share/tcltk/tcl8/8.5 /usr/share/tcltk/tcl8/8.6
/usr/share/tcltk/tcl8.6/tcl8
If I create a file called: mymodtest-0.1.tm with the following contents:
proc number {} {return 1}
I copy that file to the last location in the list above:
/usr/share/tcltk/tcl8.6/tcl8
Then I edit the file, replace the
1 with a 2, and copy the file to the previous location in the list above: /usr/share/tcltk/tcl8/8.6
Finally I edit the file again, replace the
2 with a 3, and copy the file to the previous location in the list above: /usr/share/tcltk/tcl8/8.5
When I run the following script:
package require mymodtest
number
I get a
1; if I delete the file from the last location in the list, I get a 2; if I then delete the file from the previous location I get a 3.
Referenced by3
d041733320[86ceb4e2b6] Improve reaction when multiple *tm files purport to offer the same version of the same package. Prefer the file that comes first on the tm path. Makes TCL*_TM_PATH variables more useful. Thanks to Gustaf Neumann for the suggestion. [a16752c252] Revise (partially revert) bug fix to stop crashes in buggy tclcompiler. check-in2013-09-07 22:19:49f55d921665[86ceb4e2b6] Improve reaction when multiple *tm files purport to offer the same version of the same package. Prefer the file that comes first on the tm path. Makes TCL*_TM_PATH variables more useful. Thanks to Gustaf Neumann for the suggestion. check-in2013-09-07 21:36:37d97afc2a13Possible improvement in light of [86ceb4e2b6]. check-in2013-07-15 19:09:59
dgpplain2013-07-15 17:14:55
The TM search is working as documented. Much more detail in the comp.lang.tcl followup. https://groups.google.com/d/msg/comp.lang.tcl/VXsAUOlPIXY/dXu7-Hq8dusJ
dgpplain2013-07-15 18:04:32
Re-opened. In that same comp.lang.tcl thread, Gustaf Neumann suggests a tweak that might improve this situation and related ones, yet still be faithful to the assumptions in the [package require] design.
dgpplain2013-07-15 19:11:22
See branch bug-86ceb4e2b6 for an idea how we might improve the experience of the OP while not revising the assumptions of [package require]. Thanks to Gustaf Neumann for the idea.
jan.nijtmansplain2013-09-06 22:27:15
This change looks good to me. Planned for 8.6.1?
dgpplain2013-09-08 12:18:31
Change accepted for 8.5.15 and 8.6.1.
Log in (anonymous is fine) to add a comment.