Version 20 of Most programmers don't know what Expect can do for them

Updated 2004-03-31 21:04:51

This is the theme of "Expect exceeds expectations" (see the developerworks article at: [L1 ]): even most active Expect programmers are aware of only a fraction of its capabilities.

First, they don't realize that Expect is a proper superset of Tcl, and therefore can do everything Tcl can. Moreover, they're not aware that Tcl is a quite capable general-purpose programming language.

They also are not aware of the relation between Tk and Expect, so don't realize how easy it is to add a GUI to existing Expect scripts.

Expect extends Tcl in three principal ways:

  • with pseudo-terminal (pty) management
  • with debugging facilities
  • with a command language for "challenge"-response dialogues.

In broad terms, few programmers realize the elegance of integration of pty management into Tcl's framework of event-oriented channels. [Much more explanation.]


interact is one of Expect's wonders.


Usability notice: The referenced developerWorks article contains what appear to be hyperlinks to a discussion forum. They are not hyperlinks. They are javascript directives. So, turn on your javascript, and forget about any "open in a new tab" option you may be used to when something looks like a link.

Usability followup: Once you navigate the maze above and actually reach the discussion forum, it is completely unusable. Do not waste your time. Just read the article, then go home.


Expect is a superset of Tcl? That's shocking news to me. Then how come we program in Tcl instead of Expect? Such play on words can have a mind-boggling effect on newbies.

Luciano, can we do this in clt? I don't understand whether you have an other-than-rhetorical question.

No, my dear IP number gumshoe. The wording has confused me indeed. I always thought that Expect was a Tcl application, or a Tcl subset in other words. Just tell us what "superset" means here, edit (delete) my clueless questioning and we're good. ;-)


"superset" afaik is slang, I can't find it in the dictionary, "subset" on the other hand did appear in the dictionary but, languages evolve all the time, and dictinaries add new words, so maybe it's just that I have an old dictionary.

Now, let say that c have a set of features {structs, int, functions, pointers, arrays, recursion} we can say that c++ have a larger set of features {structs, int, functions, pointers, recursion, classes, references, templates} instead we can say c++ have {{c}, classes, templates, references} which will make c's set of features a subset of c++ set of features or in simpler words we can say c is a subset of c++.

In the same way we can say Tcl is a subset of XOTcl, or snit, or Expect, etc... that XOTcloffers Tcl + more.

By the way I am a complete newbie, I have no clue how XOTcl or Expect are ditributed as a seperate interpreter or as packages/modules.

c++ publicize it self as a seperate language If you visit XOTcl homepage [L2 ] you will see similar behavior, but not exactly Expect publicize it self as tool, not a language, it doesn't even matter that it's writen in Tcl (maybe it does, but I never used it and I don't know what it does, but this is how expect pulbicize it self anyway, their mistake if any).

But regardless of all this, I think it's politicaly correct to call Tcl a subset of these tools (even if those tools are writen in Tcl, because it doesn't really matter how they were implement, maybe in c, maybe in ocaml or c++, and we alse can't claim that Tcl is a subset of Tkman, Tkman being writing in Tcl, we can say so about XOTcl or Expect for what they do, not how they were implemented), and maybe even enlightening, cause now I know that if I learn Tcl well, I will have no problem using these tools


RJ 3/31/04 - Allow me to suggest a compromise. In most of the Expect documentation I have, (e.g., Exporing Expect) Expect is referred to as an extension of TCL. It was written by Don Libes at NIST - in TCL - after John Ousterhout announced TCL. It has since been adapted as an extension to other languages.


Category Expect