Sunday, January 3, 2010

Issues with TCL and Expect

Issues with TCL:

* scope is insane. There is no automatic inheritance of variables
from the global scope. If you want a variable from the parent
scope, you need to declare this by using the "global" keyword.
There are various other kinds of scope you can do, including going
into the caller's scope.

* the language is barely tokenized at all. If there is a basic syntax
bug, the interpreter is likely to not pick up on it until that
particular code path is run.

* There are no forward declarations of functions. If you want to use
a function, you have to define it before you use it.

Issues with expect:

* the documentation encourages people to do "send "$whatever\r";
expect $prompt". In a lot of cases, though, sending $whatever will
result in a prompt regardless of whether it also resulted in an
error or not. This encourages sloppy code. Better guidance might
be "send "$whatever\r"; expect "$whatever\r\n$prompt", because that
checks that the host returned a prompt immediately after echoing
$whatever.

* Bad things can happen under three special error conditions: eof,
timeout, and full_buffer. It would be nice if there were a default
handler for these that threw an exception, to force programmers to
be aware of them. The handler could be an expect_after_after, so if
the programmer tests for them in expect_before, expect, or
expect_after, that test overrides. It might be triggered by a
special syntax (i.e. expect_sanity or something) so as to avoid
problems with backwards compatibility.