Tcl namespaces and private procedures and variables

Gustaf Neumann neumann at wu.ac.at
Fri Oct 12 01:06:58 UTC 2018


On 10.10.18 04:09, Ryan Schmidt wrote:
> Well, you could say that's also the purpose of the naming conventions we've used in other portgroups. The naming of the github.setup procedure and the github.homepage option and so forth are intended to convey that they are part of the github portgroup. I realize that from Tcl's standpoint the "." in the name is no different than any other character, so technically these is just a top-level procedures and options like any a port could define, but conceptually they're meant to be seen as part of the portgroup.
exactly
> I assume that for example if I migrate the github portgroup to use a namespace, I will hide internal procedures like handle_tarball_from inside the namespace, while keeping things a Portfile is intended to use, like github.setup and github.homepage, outside of the namespace.

Tcl namespaces can contain commands, variables and other namespaces.
Namespaced items can be always addressed with the full path (starting 
with "::")
and sometimes without the namespace prefix (e.g. inside a "namespace 
eval", or
when namespaced items are exported). Namespace-exported commands
are often used as the (public) interface to a package, while the 
non-exported commands
are regarded as package-internal.

The Tcl library contains many examples of namespace usages, see e.g. [1]

[1] https://core.tcl.tk/tcllib/artifact/812f146bfc1a12bb



More information about the macports-dev mailing list