32. Tcl Objects

In Tcl, all values can be treated as strings. Early versions of Tcl actually stored all values as strings, even numeric data types. This approach could be quite slow, especially for values that needed frequent conversion to binary formats, such as floating-point numbers.

In contrast, all modern versions of Tcl (ever since 8.0, released in 1997) store their data internally using a much more efficient form called Tcl objects. Tcl objects are values that have a string representation and a second “internal” representation of some other type, such as integer, double, list, or, in Tcl 8.5, dictionaries. Tcl uses objects internally for variable values, command arguments, command results, and scripts.

This dual nature of Tcl objects ...

Get Tcl and the Tk Toolkit, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.