Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Upcoming Tcl, Expect, Tk courses ... Learning to program in Tcl and Expect
Tcl and Expect programming
The Tk Toolkit

Tips and short articles on this subject
Tcl - learning how to use namespaces, packages and libraries together
Packages and Namespaces are like Suitcases and Aircraft
example of Tcl namespaces and packages
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 Basics

Tcl Programming - The Tcl programming language, and Expect This course covers the fundamentals of the Tcl programming language. You'll learn about Tcl ...
http://www.wellho.net/course/tbfull.html  [course]
Learning to Program in Tcl - The Tcl programming language, and Expect This course covers the fundamentals of the Tcl programming language. You'll learn ...
http://www.wellho.net/course/tlfull.html  [course]
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 ...
http://www.wellho.net/mouth/146_exam ... kages.html  [short article]
Tcl procs (they're Tcl's functions) can pass information back via the return command, and they can access data in the top level of code via the global ...
http://www.wellho.net/mouth/2476_Tcl ... level.html  [short article]
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 ...
http://www.wellho.net/mouth/1529_Tcl ... ether.html  [short article]
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 ...
http://www.wellho.net/mouth/1339_Pac ... craft.html  [short article]
#!/usr/bin/tcl # Count calls to a proc, use namespaces namespace eval fingers { variable currentcount 0 namespace export counter proc ...
http://www.wellho.net/resources/ex.php4?item=t213/ns_exim  [code sample]

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.

This topic is presented on public courses Learning to program in Tcl, Tcl Basics

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
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
packs   Loading a package
show.tcl   Defining 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
Pictures
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 http://www.training-notes.co.uk.
Topics covered in this module
Startup files.
Libraries and packages.
Locating and loading packages.
Using variables across procs and packages.
Namespaces.
Exporting and importing.
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,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. Also available is the Opentalk Forum for discussion of technical questions.


You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 0800 043 8225 or 01225 708225 • FAX: 01225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho