For 2021 - online Python 3 training - see ((here)).
Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.
Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
What 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 Mary Erin Benjamin James and Elizabeth too. On occasions, we need to make compromises when a father is named after his son - such as referring to the son as John_Boy.
What chance is there that two of these people will have the same forename?
It's quite low!
But what happens as our community grows? As we pull in code from elsewhere, we also find that we have the same names cropping up again. The next family added may have no repeats - Abi amd Jack, Dot and Jim, Lauren and Max, and Lily and Oscar. Bradley, Ronnie and Stacey. But then - look carefully - you start getting repeats. There's Dan and Grace, Phil and Jill, Kenton, Shula, David and Elizabeth, Lillian, Tony, Helen and Tom. And as the list grows, more and more possibilities of a repeat.
But what chance is there that two of these people will have the same forename?
It's highly unlikely that everyone here will have a different forename.
We can solve issues caused by this repetition of names by using family names - we've got the Brannigans, the Waltons and the Archers. We can identify each individual by forename and family name - Jason Walton, Jim Brannigan, Elizabeth Archer, Elizabeth Walton and with the extra qualification we know whether we're lookig at somewhere in Virginia, or the lady of Lower Loxley Hall.
Namespaces in Tcl (and packages in Perl) are like family names - we group whole sets of variables together within a namespace, and we can then refer to them by a fully qualified name which makes it clear exactly which of several of the same name we're referring too. Within an individual namespace / package area though we can refer to variable just by their name within the namespace, just as round the family table we'll talk to Jack or Jim or - in a different part of the country - David or Elizabeth.
Programming wise, the use of namespaces allows different developers to provide cde which can more easily be shared without the need (prior to coding) for an agreement to be reached as to who's going to use what name. And that becomes important as code grows, with major coding elements loadable from shared libraries having just a single (family) name brought into the parent namespace. On a course such as the Tcl course which I gave last week, examples tend to be quite short which means that the true significance of namespaces as programs grow has to be talked obout much more in theory than in practise, though we can (and do) do a practical exercise.
There's an example [here] from yesterday's course that shown namespaces. The code is all in one file (that's easier for a first demo than having multiple files to manage) and withn our namespace we've defined 3 procs to work out the area, circumference, and doggie distance of a rectangular table (the doggie distance is the maximum distance from the edge of the table that a treat can be place to keep it out of the dog's reach).
Namespaces are often used in association with packages. Technically, they're different facilities but in practise they're usually used together. There's a follow up article [here] introducing packages
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesT213 - Tcl/Tk - Libraries, Packages and Namespaces
 example of Tcl namespaces and packages - (2004-12-10)
 Packages and Namespaces are like Suitcases and Aircraft - (2007-09-09)
 Tcl - learning how to use namespaces, packages and libraries together - (2008-02-02)
 Tcl - uplevel to run code at calling level - (2009-10-24)
 Separating groups of variables into namespaces - (2010-11-24)
 Tcl packages, pkg_mkIndex, pkgIndex.tcl -what are they and why use them. - (2011-09-03)
 Loading packages in your Tcl program - (2015-10-09)
Some other Articles
Ruby off the Rails?
Making best use of the new enthusiasm for Melksham
Data that we use during our training courses, and other training resources
What is a namespace and why do we need them?
Storing Tcl source code encoded, and running via your own C program
User defined sorting and other uses of callbacks in Tcl and Tk
Passing back multiple results in Tcl - upvar and uplevel
If its Sunday, must it be Weymouth?
Handling binary data in Perl is easy!
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page
This is a page archived from The Horse's Mouth at
the diary and writings of Graham Ellis.
Every attempt was made to provide current information at the time the
page was written, but things do move forward in our business - new software
releases, price changes, new techniques. Please check back via
our main site for current courses,
prices, versions, etc - any mention of a price in "The Horse's Mouth"
cannot be taken as an offer to supply at that price.
Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).