Alan Collins

I work for San Diego State University in Business Information Systems. My previous position was with Computer Sciences Corp (CSC), as a Consultant/Programmer/analyst.

I have been using TCL/TK for personal use since 1995, heavily the last 6 or seven years. I was interested in developing editors and tools for software development for my own use.

I may occasionally be seen listening in the chat area as AEC.

I'll post more here as time permits.

After 5 years of retirement I have decided I have time to describe my style and method of developing with Tcl.

My development environment consists of a modified version of eZdit as my ide. Within eZdit I use a recent version of tclkit as my runtime for testing.

I usually develop my applications as starpacks. In my main.tcl, especially during development, I source a custom kitten which contains every package I have developed, also those available from Activestate or found on this wiki that I have found useful in the past. When I create the final starpack I will either place the needed packages in the lib directory of the starpack or create a new custom kitten to be sourced by the application.

My apps are usually developed as packages and packages as namespace ensembles. The pkgIndex.tcl looks like this:

proc myPkgSetup {dir pkg version files} {
        global auto_index
        package provide $pkg $version
        foreach fileInfo $files {
                set f [lindex $fileInfo 0]
                set type [lindex $fileInfo 1]
                foreach cmd [lindex $fileInfo 2] {
                        if {$type eq "load"} {
                                set auto_index($cmd) [list load [file join $dir $f] $pkg]
                        } else {
                                set auto_index($cmd) [list $type [file join $dir $f]]
proc mySource {f} {
        set pns {}
        set ns [file root [file tail $f]]
        # files foo~bar.tcl are loaded into foo namespace, but only if present
        if {![regsub {~.*} $ns {} ns]} {
                namespace eval ${pns}::${ns} {
                        namespace export -clear {[a-z]*}
                        namespace ensemble create
                lappend modules $ns
        } elseif {![namespace exists ${pns}::$ns]} {
                tclLog "[file tail $f]: skipped, module $ns doesn't exist"
        namespace inscope ${pns}::${ns} source $f
        if {$pns ne {}} {interp alias {} $ns {} ${pns}::${ns}}
if {[catch {package require Tcl}]} return
package ifneeded app 1.0 "\
        package require Tk 8.6.8;\
        [list myPkgSetup $dir app 1.0 {
                {components/cmd1.tcl mySource {cmd1}}
                {components/cmd2.tcl mySource {cmd2}}

As seen above, the package may have one or more ensembles found in a "components" sub directory of the package. The directory structure for the package would look like this:

  • package directory
  • - pkgIndex.tcl
  • - "component" (sub directory of package)
  • -- cmd1.tcl (ensemble cmd1)
  • -- cmd2.tcl {ensemble cmd2)

More later