Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))

Well House Consultants
You are on the site of Well House Consultants who provide Open Source Training Courses and business hotel accommodation. You are welcome to browse and use our resources subject to our copyright statement and to add in links from your pages to ours.
Other subject areas - resources
Java Resources
Well House Manor Resources
Perl Resources
Python Resources
PHP Resources
Object Orientation and General topics
MySQL Resources
Linux / LAMP / Tomcat Resources
Well House Consultants Resources
Extras Resources
C and C++ Resources
Ruby Resources
Tcl/Tk Resources
Web and Intranet Resources
Tcl/Tk module T213
Libraries, Packages and Namespaces
Exercises, examples and other material relating to training module T213. This topic is presented on public courses Learning to program in Tcl, Tcl Programming, Tcl Programming

As your code grows, you'll want to divide it into series of modules. These are known as packages in Tcl. You'll also want to use a separate namespace so that procedure names in one package don't conflict with the same procedure name in another. Libraries allow you to load code in C as well as Tcl into your interpreter.

Articles and tips on this subjectupdated
4522Loading packages in your Tcl program
In Tcl, extra bundles of code can be loaded from packages which are files of more ... brought in with package require from a folder that's listed in the auto_path variable. Packages are defined with a package provide in the source code of the package which must be indexed in a file called pkgIndex.tcl. ...
3417What is a namespace and why do we need them?
We name variables. We do it so that we can identify specific pieces of data by a key, rether than have to give some longer sort of identification description when referring to them. We don't refer to "the patriarch of the household" = we refer to Zeb. And we refer to Esther, John and Olivia, Jason ...
3418Tcl packages, pkg_mkIndex, pkgIndex.tcl -what are they and why use them.
In the previous article [here], I wrote about namespaces and how - as our program grows - we need to keep named pieces of code and globally accessible variable in their own groups. And we do so using a structure that's very much like family names and forenames. As our program grows, we also need to ...
3066Separating groups of variables into namespaces
If your program's going to grow in size beyond a certain point, you'll need to use some sort of namespace or package to segment global names into different groupings - moving from a single name to a forename / surname type system, if you like to think of it that way. In C++, it's namespaces - see [here] ...
1529Tcl - learning how to use namespaces, packages and libraries together
Tcl supports both packages (which allow code to be loaded from libraries at run time) and namespaces (which allow for procs and variables to be grouped together to allow you to avoid conflicts as you use code from lots of different sources). Strictly speaking, the two sets of facilities are independent ...
1339Packages and Namespaces are like Suitcases and Aircraft
Are Suitcases and Aircraft the same things? No, clearly they're not, but you'll often use them in close assocoation with one another. When I was in Albany, New York State, the other week ... I travelled there from Melksham with a suitcase of luggage, and I used an Aircraft for my journey. Taking ...
146example of Tcl namespaces and packages
Packages in Tcl allow you to define a file of code that's going to be loaded as required at run time. Namespaces allow you to define a new set of variable and proc names that doesn't conflict with the variable and proc names in your main program - rather like giving all the variable and procs in part ...
Examples from our training material
2wice   Using a package that contains a namespace
dinpack   Using packages and namespaces together
doubler.tcl   define a package to contain a namespace
gpack.tcl   package goose - goes with dinpack
legals.tcl   Definition of a package
nex   packages with and without namespace
ns_exim   Namespace export and import
ns_no   shows how variables are lost between proc calls
ns_up   Variables saved between proc calls in the next code level up
ns_y2   Counting proc calls using a namespace - shorter example
ns_yes   Saving variables in a namespace
nsp   setting up and using a namespace
nsq   Adding a package to a namespace
packs   Loading a package
rules.tcl   Definition of a package with namespace
show.tcl   Defining a package
tabby.tcl   a namespace wrapped in a package
toes.tcl   Package to go with twice demo
tpack.tcl   package chicken - part of dinpack demo
twice   Using a package - without namespaces
updown   uplevel - performed in calling code variable space
Public Tcl course
Background information
Some modules are available for download as a sample of our material or under an Open Training Notes License for free download from [here].
Topics covered in this module
The load command.
Startup files.
Startup files - tcl.
Startup files - expect.
Loading packages.
Writing your own package.
Using variables across procs and packages.
Recap on using variables between procs.
Nesting of namespaces.
Exporting and importing.
Packages and namespaces.
Complete learning
If you are looking for a complete course and not just a information on a single subject, visit our Listing and schedule page.

Well House Consultants specialise in training courses in Tcl/Tk, Expect,Ruby, Lua, Python, Perl, PHP, and MySQL. We run Private Courses throughout the UK (and beyond for longer courses), and Public Courses at our training centre in Melksham, Wiltshire, England. It's surprisingly cost effective to come on our public courses - even if you live in a different country or continent to us.

We have a technical library of over 700 books on the subjects on which we teach. These books are available for reference at our training centre.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/resources/T213.html • PAGE BUILT: Sun Oct 11 14:50:09 2020 • BUILD SYSTEM: JelliaJamb