Native Inspect Manual (H06.13+, J06.03+)

# mySub.tcl
package provide mySub 1.0
namespace eval ::mySub:: {
# my package code
}
# More code
In this example, the namespace ::mySub:: contains the package mySub.
When your package is installed on a system, Tcl scripts can use your package by referring to its
namespace, not its actual location.
It is important to create your packages in your own namespaces to avoid conflicts. Each exported
subsystem command must be referenced by namespace.
Other Scripts Must Explicitly Require Your Package:
Any script that uses your package must explicitly require the package, as follows:
# In an app or another packagepackage require mySub
Explicitly Export Your Public Commands: Your package should export its public commands (but
not its private commands), as follows:
namespace eval ::mySub::: {
namespace export {[a-z]*}
}
proc ::mySub::myPublicProc{} {...}
Each namespace exports symbols that can be explicitly included, and unambiguously defined. The
definition can be nested in the namespace itself (without the namespace qualifier) or declared as
a member of the namespace, with the namespace name qualified in the proc name, as follows:
#--------------------------------------------------------
# Syntax: dcba <context> <craddr> [ <count> ]
#-------------------------------------------------------------
proc ::mySub::dcba { context craddr {count 1} } {
...
}
...
If a Tcl script is to use the commands in mySub, the caller need only reference the package as
follows:
package require mySub
Other Scripts Must Import Packages and Commands
If you have explicitly exported your public commands, another user can use a wild card to import
your public commands, as follows:
# In an app or another package
namespace eval ::mySub:: {
namespace import ::mySub::*
}
A user can invoke your help by entering the Tcl help (or tclhelp) command, as follows:
tcl help commandname
Tcl Examples
The code for the Native Inspect eq command is implemented in Tcl:
# Syntax: eq <expr>
#
# Effect: Evaluate the expression and display the result in
# different formats.
#
#-----------------------------------------------------------
Tcl Examples 131