Chapter 56. Tcl/Tk 8.2

Tcl 8.2 is primarily a bug fix and stabilization release. This release is recommended instead of Tcl 8.1.

Tcl 8.2 adds almost no new features at the Tcl script level. Instead, it adds a few new C APIs that enable some interesting extensions to be added without having to modify the core Tcl distribution. At the same time, Scriptics focused on the outstanding bug reports in order to make the 8.2 release as stable as possible.

The Trf Patch

Andreas Kupries contributed a mechanism that allows I/O channel processing modules to be stacked onto open I/O channels. This adds a new Tcl_StackChannel C API, but there are no changes visible at the Tcl script level. However, it enables several interesting extensions such as compression and encryption (e.g., SSL) to be added to Tcl. Andreas has an extension that exports the channel filter mechanism to the Tcl script level. This is used primarily for testing, but you can also use it for script-level data filters.

Faster String Operations

The UTF-8 encoding has the drawback that characters are not all the same size: They are either one, two, or three bytes in length. The variable-sized characters make operations like string length, string index, and string range quite slow in comparison to a system that uses fixed-sized characters. A new Unicode string type, which uses 16-bit characters, was added to support faster string operations. This change does not cause any changes that are visible to Tcl scripts, except for improved performance in comparison to Tcl 8.1.

Empty Array Names

Perhaps the only change in Tcl 8.2 visible to Tcl scripts is support for empty array names. This is a quirk you can get by using name spaces or upvar, but it was previously difficult to use directly. For example, the syntax $::foo::(item) references an array. That worked in any version of Tcl that supported namespaces. However, in Tcl 8.2 you can also use $(item) directly, which implies that the array name is the empty string. This trick is exploited by Jean-Luc Fontain's STOOOP object-oriented extension.

Browser Plugin Compatibility

The Web Browser plugin requires changes to the event loop mechanism because Tcl is embedded in an application with its own event loop. While the C APIs have supported alternate event loops since Tcl 8.0.3, it has been difficult to do this sort of embedding without recompiling Tcl. The Tcl_SetNotifier API was added to support embedding a "stock" Tcl interpreter.

Finer Control of Windows Serial Port Monitoring

On Windows systems, Tcl polls the serial ports for fileevents at the default rate of approximately every 10 milliseconds. Tcl 8.2 introduced the fconfigure -pollinterval option to give the ability to specify a shorter polling interval.

Regular Expression Expanded Syntax Option

Although Tcl 8.1 introduced support for expanded regular expression syntax (where whitespace and comments are ignored), it required you the signal the expanded syntax by including the (?x) option embedded in the regular expression string. Tcl 8.2 introduced the regexp -expanded option as an alternate way of enabling expanded regular expression syntax.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.128.78.30