On 6/2/2023 2:55 AM, pd wrote:
El jueves, 1 de junio de 2023 a las 16:28:02 UTC+2, Mark escribió:
I read the docs for tm and they say "A Tcl Module is a Tcl Package contained in a single file, and no other files required by it". This seems a bit restrictive compared to the package approach. And anyway, I'm only really looking at how to spread an
application over multiple files; all the tcl files are for the application, they're not self-contained as such.
so what's the real difference between a package and a module in terms of use? it seems modules are just an evolution over packages intended to the same use.
After reading the replies in this thread (and without reading any doc), I have a doubt, if package provide is not required in a module, how tcl knows what names you want to export in the module? is it the case that all symbols defined in the module
are public by default (and thus imported when you do a package require)?
One can use a [package provide] command if one really
wants to, but it's not necessary. If used, it does add
a slight maintenance cost, since it will need to be
updated if/when a new version is added. It has to
agree with the version that the file name is encoded with.
Modules, like packages, are intended to be code that
forms a library where ordinarily more than one program
will be using the code. For example, the http package
is actually provided as a module. A module is simply
a lite weight package, that is pure tcl and can be
loaded via a source command.
One can use the *list* subcommand to find which of the
directories are built in searches similar to how the
global auto_path is setup. For example,
$ tclsh
% join [tcl::tm::path list] \n
/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
$ ls /usr/share/tcltk/tcl8.6/tcl8
http-2.9.0.tm msgcat-1.6.1.tm platform-1.0.14.tm tcltest-2.5.0.tm
So, if one wants to supply a module that does not
need a [tcl::tm::path add] one can place a module
into one of the *known* directories listed above.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)