Sujet : Re: Installing a module
De : wortkarg3 (at) *nospam* yahoo.com (Harald Oehlmann)
Groupes : comp.lang.tclDate : 23. Jun 2025, 12:28:37
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <103bdp4$162l4$1@dont-email.me>
References : 1 2
User-Agent : Mozilla Thunderbird
Am 23.06.2025 um 05:58 schrieb Rich:
saito <saitology9@gmail.com> wrote:
Modules seem to refuse this simplicity. A module is supposed be a
single file. But I am not sure this is true in practice.
This is in reference to the Tcl interpreter view, not the "human
distributor viewpoint".
So there is a module I want to use. It comes as a zipped file. Unzipped,
it has a readme, a copyright file, a subfolder, and a .tm file.
The only "module" file present there (as far as Tcl is concerned) is
the .tm file. That is the "module", and is all Tcl will look for when
you try to package require the module. The other files are essentially
side-cars for human use. The subfolder may or may not contain files
that the code inside the .tm uses, so it may, or may not, be needed.
I could create a folder dedicated to modules, adjust the tm paths, and
put all those in there. At first, this seems like it will work.
If all your .tm files do not try to consume other files (code in a
mudule can do anything Tcl can do) you could have a single directory
containing 100 .tm files, and be able to package require any one to
all, by pointing the module path at that single directory. And you
could continue to add more by adding more .tm files there.
However, what happens when I want to use a new module? Presumable it too
will have its own readme, copyright, etc. So I can't just put it in that
folder as it will overwrite the previous module. So I need to create a
new folder, revise the tm paths, etc.
Only if you wish to keep copies of all the side-car files present for
human consumption. If you just want a collection of modules, you don't
need the side-cars (for package require purposes). Of course, if in X
years you wonder where module blah.tm came from, not having the
side-car files around might make the task of tracking it down a bit
more difficult.
Perhaps an additional information:
the search path for ".tm" files and "pckIndex.tcl files is different:
set auto_path
-> search path for pckIndex.tcl files
::tcl::tm::path list
-> search for .tm files
The idea of .tm files is, that basically the pckIndex.tcl is included in the file name for single file packages.
So a package "demo" has:
demo/pckIndex.tcl
demo/demo.tcl
where "pckIndex.tcl" has the content: "package ifneeded demo 1.0 [list source [file join $dir demo.tcl]]"
Then, the one file distribution as .tm file can be created by:
file copy demo/demo.tcl demo-1.0.tm
The pckIndex.tcl is not needed any more.
Harald