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 thenamespacecommand 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 likeinfo objectsandinfo classesinto the usualinfocommand. These functions have been moved to a newitcl::findcommand.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
CHANGESfile in theiwidgets3.0.0directory. Because there are a lot of changes, this distribution also contains theiwidgets2.2.0package, 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 barneynamespace delete foo itcl::delete objects fred barneyinfo contextnamespace currentinfo objects ...itcl::find objects ...info classes ...itcl::find classes ...info which -namespace $nameif {![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 #autoIn 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 #autoIn itcl2.2, the globalcommand was used to access variables in a namespace:namespace foo { variable x 0 proc example {} { global x return $x } }In Tcl8.0, the variablecommand 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
- You can now use instance variables (along with the usual common variables) with the
scopecommand. Thus, you're no longer forced to use the trick with a common array, such as:[scope modes($this)]
- All widget/mega-widget access commands (e.g.,
.foo.bar) are installed in the global namespace. Therefore, they can be accessed from any namespace context.
- The [incr Widgets] package used to be loaded by default. You must now use the
package requirecommand to load it explicitly:package require Iwidgets <-- loads the lastest (iwidgets3.0.0) package require -exact Iwidgets 2.2 <-- loads the older release
- Command/variable names are now reported with fully-qualified names in
infoinquiries and in error messages.
- No
public/protected/privatedeclarations outside of class definitions
- The
scopecommand used to be more or less the same as thecodecommand. In itcl3.x,scopeis only for variables, and if a variable is not recognized, you'll get an error.
- The
codecommand used to return a value like "@scope ...". It now returns "namespace inscope ...", to be compatible with Tcl8.
- The prototypes for
Itcl_RegisterCandItcl_FindChave changed. You can now includeClientDatawhen you register C functions. Also, there is a newItcl_RegisterObjCfunction for(objc,objv)-style command handlers.