Summary of Major Changes in Tcl/Tk 8.0
Tcl Feather Logo

Tcl Logo Summary of Major Changes in Tcl8.0

Here are the most significant changes in Tcl 8.0. In addition to these changes, there are several smaller changes and bug fixes. See the file "changes" for a complete list of all changes.

  1. Bytecode compiler. The core of the Tcl interpreter has been replaced with an on-the-fly compiler that translates Tcl scripts to byte codes; a new interpreter then executes the byte codes. In earlier versions of Tcl, strings were used as a universal representation; in Tcl 8.0 strings are replaced with Tcl_Obj structures ("objects") that can hold both a string value and an internal form such as a binary integer or compiled bytecodes. The new objects make it possible to store information in efficient internal forms and avoid the constant translations to and from strings that occurred with the old interpreter. We have not yet converted all of Tcl to take full advantage of the compiler and objects and have not converted any of Tk yet, but even so you should see speedups of 2-3x on many programs and you may see speedups as much as 10-20x in some cases (such as code that manipulates long lists). Future releases should achieve even greater speedups. The compiler introduces only a few minor changes at the level of Tcl scripts, but it introduces many new C APIs for managing objects. See, for example, the manual entries doc/*Obj*.3.

  2. Namespaces. There is a new namespace mechanism based on the namespace implementation by Michael McLennan of Lucent Technologies. This includes new "namespace" and "variable" commands. There are many new C APIs associated with namespaces, but they will not be exported until Tcl 8.1. Note: the syntax of the namespace command has been changed slightly since the b1 release. See the changes file for details.

  3. Binary I/O. The new object system in Tcl 8.0 supports binary strings (internally, strings are counted in addition to being null terminated). There is a new "binary" command for inserting and extracting data to/from binary strings. Commands such as "puts", "gets", and "read" commands now operate correctly on binary data. There is a new variable tcl_platform(byteOrder) to identify the native byte order for the current host.

  4. Random numbers. The "expr" command now contains a random number generator, which can be accessed via the "rand()" and "srand()" math functions.

  5. Safe-Tcl enhancements. There is a new "hidden command" mechanism, implemented with the Tcl commands "interp hide", "interp expose", "interp invokehidden", and "interp hidden" and the C APIs Tcl_HideCommand and Tcl_ExposeCommand. There is now support for safe packages and extension loading, including new library procedures such as safe::interpCreate (see the manual entry safe.n for details).

  6. There is a new package "registry" available under Windows for accessing the Windows registry.

  7. There is a new command "file attributes" for getting and setting things like permissions and owner. There is also a new command "file nativename" for getting back the platform-specific name for a particular file.

  8. There is a new "fcopy" command to copy data between channels. This replaces and improves upon the not-so-secret unsupported old command "unsupported0".

  9. There is a new package "http" for doing GET, POST, and HEAD requests via the HTTP/1.0 protocol. See the manual entry http.n for details.

  10. There are new library procedures for finding word breaks in strings. See the manual entry library.n for details.

  11. There are new C APIs Tcl_Finalize (for cleaning up before unloading the Tcl DLL) and Tcl_Ungets for pushing bytes back into a channel's input buffer.

  12. Tcl now supports serial I/O devices on Windows and Unix, with a new fconfigure -mode option. The Windows driver does not yet support event-driven I/O.

  13. The lsort command has new options -dictionary and -index. The -index option allows for very rapid sorting based on an element of a list.

  14. The event notifier has been completely rewritten (again). It should now allow Tcl to use an external event loop (like Motif's) when it is embedded in other applications. No script-level interfaces have changed, but many of the C APIs have.

    Tcl8.0 Incompatibilities

    Tcl 8.0 introduces the following incompatibilities that may affect Tcl scripts that worked under Tcl 7.6 and earlier releases:

    1. Variable and command names may not include the character sequence "::" anymore: this sequence is now used as a namespace separator.

    2. The semantics of some Tcl commands have been changed slightly to maximize performance under the compiler. These incompatibilities are documented on the Web so that we can keep the list up-to-date. See the URL http://www.sunlabs.com/research/tcl/compiler.html.

    3. 2-digit years are now parsed differently by the "clock" command to handle year 2000 issues better (years 00-38 are treated as 2000-2038 instead of 1900-1938).

    4. The old Macintosh commands "cp", "mkdir", "mv", "rm", and "rmdir" are no longer supported; all of these features are now available on all platforms via the "file" command.

    5. The variable tcl_precision is now shared between interpreters and defaults to 12 digits instead of 6; safe interpreters cannot modify tcl_precision. The new object system in Tcl 8.0 causes floating-to-string conversions (and the associated rounding) to occur much less often than in Tcl 7.6, which can sometimes cause behavioral changes.

    6. The C APIs associated with the notifier have changed substantially.

    7. The procedures Tcl_CreateModalTimeout and Tcl_DeleteModalTimeout have been removed.

    8. Tcl_CreateFileHandler and Tcl_DeleteFileHandler now take Unix fd's and are only supported on the Unix platform

    9. The C APIs for creating channel drivers have changed as part of the new notifier implementation. The Tcl_File interfaces have been removed. Tcl_GetChannelFile has been replaced with Tcl_GetChannelHandle. Tcl_MakeFileChannel now takes a platform- specific file handle. Tcl_DriverGetOptionProc procedures now take an additional interp argument.

    Tcl Logo Summary of changes in Tk 8.0

    Here is a list of the most important new features in Tk 8.0. The release also includes several smaller feature changes and bug fixes. See the "changes" file for a complete list of all changes.

    1. Native look and feel. The widgets have been rewritten to provide (nearly?) native look and feel on the Macintosh and PC. Many widgets, including scrollbars, menus, and the button family, are implemented with native platform widgets. Others, such as entries and texts, have been modified to emulate native look and feel. These changes are backwards compatible except that (a) some configuration options are now ignored on some platforms and (b) you must use the new menu mechanism described below to native look and feel for menus.

    2. There is a new interface for creating menus, where a menubar is implemented as a menu widget instead of a frame containing menubuttons. The -menu option for a toplevel is used to specify the name of the menubar; the menu will be displayed outside the toplevel using different mechanisms on each platform (e.g. on the Macintosh the menu will appear at the top of the screen). See the menu demos in the widget demo for examples. The old style of menu still works, but does not provide native look and feel. Menus have several new features:
      • New "-columnbreak" and "-hideMargin" options make it possible to create multi-column menus.
      • It is now possible to manipulate the Apple and Help menus on the Macintosh, and the system menu on Windows. It is also possible to have a right justified Help menu on Unix.
      • Menus now issue the virtual event <<MenuSelect>> whenever the current item changes. Applications can use this to generate help messages.
      • There is a new "-direction" option for menubuttons, which controls where the menu pops up revenues to the button.

    3. The font mechanism in Tk has been completely reworked:
      • Font names need not be nasty X LFDs: more intuitive names like {Times 12 Bold} can also be used. See the manual entry font.n for details.
      • Font requests always succeed now. If the requested font is not available, Tk finds the closest available font and uses that one.
      • Tk now supports named fonts whose precise attributes can be changed dynamically. If a named font is changed, any widget using that font updates itself to reflect the change.
      • There is a new command "font" for creating named fonts and querying various information about fonts.
      • There are now officially supported C APIs for measuring and displaying text. If you use these APIs now, your code will automatically handle international text when internationalization is added to Tk in a future release. See the manual entries MeasureChar.3, TextLayout.3, and FontId.3.
      • The old C procedures Tk_GetFontStruct, Tk_NameOfFontStruct, and Tk_FreeFontStruct have been replaced with more portable procedures Tk_GetFont, Tk_NameOfFont, and Tk_FreeFont.

    4. Application embedding. It is now possible to embedded one Tcl/Tk application inside another, using the -container option on frame widgets and the -use option for toplevel widgets or on the command line for wish. Embedding should be fully functional under Unix, but the implementation is incomplete on the Macintosh and PC.

    5. Tk now works correctly with Safe-Tcl: it can be loaded into safe interpreters using safe::loadTk.

    6. Text widgets now allow images to be embedded directly in the text without using embedded windows. This is more efficient and provides smoother scrolling.

    7. Buttons have a new -default option for drawing default rings in a platform-specific manner.

    8. There is a new "gray75" bitmap, and the "gray25" bitmap is now really 25% on (due to an ancient mistake, it had been only 12% on). The Macintosh now supports native bitmaps, including new builtin bitmaps "stop", "caution", and "note", plus the ability to use bitmaps in the application's resource fork.

    9. The "destroy" command now ignores windows that don't exist instead of generating an error.

      Tk8.0 Incompatibilities

      Tk 8.0 introduces the following incompatibilities that may affect Tcl/Tk scripts that worked under Tk 4.2 and earlier releases:

      1. Font specifications such as "Times 12" now interpret the size as points, whereas it used to be pixels (this was actually a bug, since the behavior was documented as points). To get pixels now, use a negative size such as "Times -12".

      2. The "-transient" option for menus is no longer supported. You can achieve the same effect with the "-type" field.

      3. In the canvas "coords" command, polygons now return only the points that were explicitly specified when the polygon was created (they used to return an extra point if the polygon wasn't originally closed). Internally, polygons are still closed automatically for purposes of display and hit detection; the extra point just isn't returned by the "coords" command.

      4. The photo image mechanism now uses Tcl_Channels instead of FILEs, in order to make it portable. FILEs are no longer used anywhere in Tk. The procedure Tk_FindPhoto now requires an extra "interp" argument in order to fix a bug where images in different interpreters with the same name could get confused.

      5. The procedures Tk_GetFontStruct, Tk_NameOfFontStruct, and Tk_FreeFontStruct have been removed.

      Note: the new compiler in Tcl 8.0 may also affect Tcl/Tk scripts; check the Tcl documentation for information on incompatibilities introduced by Tcl 8.0.

      Content copied from tcl8.0 and Tk8.0 README and converted to html 10 Oct97
      Hops (hops@sco.com) $ Last Modified: $Date: 1995/11/14 17:34:15 $: