[incr Tcl] 3.0

Porting Guide

As much as possible, I've tried to make itcl3.0 backward-compatible with earlier releases. The class definition syntax has not changed at all from itcl2.2, and the old itcl1.x syntax is still supported. But you'll notice changes related to namespaces. John Ousterhout adopted a slightly different namespace model for Tcl8. The syntax of the namespace command is different, as well as the semantics for command/variable lookups and imports. Also, John failed to adopt ensembles into the Tcl core, so itcl can't add functions like info objects and info classes into the usual info command. These functions have been moved to a new itcl::find command.

The [incr Widgets] package has changed quite a bit. There are many new widgets, and some of the existing widgets were streamlined--some of the widget options were removed to improve performance. For details, see the CHANGES file in the iwidgets3.0.0 directory. Because there are a lot of changes, this distribution also contains the iwidgets2.2.0 package, which is backward-compatible with the existing [incr Widgets].

It should be quite easy for most people to migrate their code to work with itcl3.0. I updated two releases of the entire [incr Widgets] library in a few hours.

Following is a quick summary of changes, to serve as a porting guide.

You have code like this... Change to this...

    namespace foo {...}

    namespace eval foo {...}

    delete namespace foo

    ::delete objects fred barney

    namespace delete foo

    itcl::delete objects fred barney

    info context

    namespace current

    info objects ...

    itcl::find objects ...

    info classes ...

    itcl::find classes ...
    info which -namespace $name

    if {![string match ::* $name]} {
        set name [namespace current]::$name    
In itcl2.2, commands/classes could be found in any namespace in a hierarchy. So within a namespace like "iwidgets" you could use simple names like:
    Labeledwidget::alignlabels ...
    Pane #auto
In Tcl8.0, all commands/classes that are not in the global namespace must be qualified. For example, the "iwidgets" namespace has a bunch of classes within it. You must always refer to these classes with qualified names, like this:
    iwidgets::Labeledwidget::alignlabels ...
    iwidgets::Pane #auto
In itcl2.2, the global command was used to access variables in a namespace:
    namespace foo {
        variable x 0
        proc example {} {
            global x
            return $x
In Tcl8.0, the variable command is used to access variables in a namespace:
    namespace eval foo {
        variable x 0
        proc example {} {
            variable x
            return $x

    public itk_component add...
    protected itk_component add...
    private itk_component add...

    itk_component add ...
    itk_component add -protected ...
    itk_component add -private ...

    bind .foo <Enter> [code %q method]
    bind .foo <Enter> [code %Q method]

    bind .foo <Enter> [code %W method]
    bind .foo <Enter> [code $this method]

Other Differences