Updated 2014-03-11 10:46:52 by RLE

One of the more obscure changes made in Tcl 8.4 is that the character \u001a (control-Z, \032) is treated as the end of file on all platforms. There are several reasons why this was done.

First, it improves script portability between Windows and other systems. Prior to this change, there was some likelihood that scripts created on Windows and transferred to other platforms would get errors at the end of the file, because the end-of-file mark, and whatever junk followed it, would be interpreted as Tcl code. It was felt that it would be better to make the handling consistent on all platforms.

Moreover, there is a use, even on non-Windows platforms, for a logical end-of-file. Starkit, for instance, uses the character to mark the end of the initialization script. While a Starkit consists of a Tcl script followed by a Metakit database, the interpreter doesn't have to know that; all it needs to know is that it should stop interpreting at the ^Z character. Other single-file Tcl applications have also put this behavior to good use.

It isn't at all difficult to get around this problem; just don't put your binary data directly in your source file. Instead, encode it somehow, and use binary, base64, or \x or \u substitution to put it in the string. Most Tcl'ers consider that to be a good practice whenever working with binary data in a script.