One of the reasons for creating Tarcel was to make it easier to create modules out of multiple files. Modules have definite benefits: they are faster to load and are simpler to deploy.

As an example, if you have the following files that you would like to put together to form a module called translator-0.1.tm:

translator.tcl
lib/deutsch.tcl
lib/english.tcl
lib/italiano.tcl

translator.tcl contains:

namespace eval translator {
  variable translations [dict create]
}

proc translator::addTranslations {language _translations} {
  variable translations
  dict set translations $language $_translations
}

source lib/deutsch.tcl
source lib/english.tcl
source lib/italiano.tcl

proc translator::englishTo {language englishWord} {
  variable translations
  dict get $translations $language $englishWord
}

lib/deutsch.tcl contains:

translator::addTranslations deutsch {
  welcome willkommen
}

lib/english.tcl contains:

translator::addTranslations english {
  welcome welcome
}

lib/italiano.tcl contains:

translator::addTranslations italiano {
  welcome benvenuti
}

You can create a module, translator-0.1.tm, from these files using the following translator.tarcel file:

set files [list \
  translator.tcl \
  [file join lib deutsch.tcl] \
  [file join lib english.tcl] \
  [file join lib italiano.tcl]
]

set version 0.1
set baseDir translator-$version.vfs
set outputFilename translator-$version.tm

import [file join $baseDir app] $files

config set version $version
config set homepage "http://example.com/project/translator"

set initScript {
  source [file join @baseDir app translator.tcl]
}

config set init [string map [list @baseDir $baseDir] $initScript]
config set outputFilename $outputFilename

Wrap the files into a module using the following:

$ tclsh tarcel.tcl wrap translator.tarcel

Now create a test file, translator.test.tcl:

package require tcltest
namespace import tcltest::*

::tcl::tm::path add [file normalize .]
package require translator

test englishTo-1 {Ensure translates from English to German} -body {
  translator::englishTo deutsch welcome
} -result {willkommen}

test englishTo-2 {Ensure translates from English to Italian} -body {
  translator::englishTo italiano welcome
} -result {benvenuti}

cleanupTests

Finally you can now run the test and see that it treats the module just as if it was originally created as a single file:

$ tclsh translator.test.tcl

Find out More

To find out more have a look at the Tarcel Project page and the following articles:
<ul id="briefPosts">

    <li><a href="/articles/2015/06/30/tarvel-v0.3-released">Tarcel v0.3 Released</a></li>
  

  

  
    <li><a href="/articles/2015/06/26/tarvel-v0.2-released">Tarcel v0.2 Released</a></li>
  

  
    <li><a href="/articles/2015/06/23/wrapping-an-application-with-tarcel">Wrapping an Application with Tarcel</a></li>
  

  

  
    <li><a href="/articles/2015/06/22/tarvel-v0.1-released">Tarcel v0.1 Released</a></li>

</ul>