Below is the list of pages for this tag.

Using TLS connections from Tcl

Published

The use of the Transport Layer Security (TLS, formerly known as SSL) is becoming increasingly prevalent to secure network communication, particularly with the browser and search companies pushing web sites to move to HTTPS instead of HTTP. This post discusses the options for using TLS over Tcl sockets and specifically some important potential pitfalls to keep in mind with respect to certificate validation. The discussion is limited to client-side operation.

(read more ...)

Tracking device changes with Tcl

Published

Windows can send notifications to applications advising them of changes in device configuration. The most common manifestation of this is file managers popping up a window showing the contents of a USB pen drive when it is plugged in and automatically closing it when the drive is ejected. This post describes how to hook into these notifications within a Tcl application.

(read more ...)

Parsing via metaprogramming

Published , updated

This blog post is adapted from my book The Tcl Programming Language.

What is metaprogramming? Roughly speaking, metaprogramming involves writing a program that in turn writes a program to do the desired task. In some cases metaprogramming makes for simpler or more succinct code while in others it optimizes performance by generating specialized code at runtime. Tcl lends itself naturally to this style of programming. This article illustrates one such use.

(read more)

Transforming recursion to iteration via coroutines

Published , updated

This blog post is adapted from my book The Tcl Programming Language.

Many programming tasks are very simply expressed and implemented through recursive algorithms, traversing a tree data structure being just one example. The primary reason recursion simplifies implementation is that the state of the computation is implicitly maintained, freeing the programmer from the burden of explicitly tracking the computational state of the program. For example, in a recursive tree walking implementation, the "current location" in the tree is implicitly tracked.

However, there are situations where a recursive model does not fit the needs of an application. For example, the application may want to traverse a tree in iterative fashion, retrieving one node at a time, operating on it and then potentially doing some unrelated computation before retrieving the next node at some unknown point in the future.

Here is where coroutines can bridge the impedance mismatch, presenting an iterative interface to a naturally recursive algorithm.

(read more ...)

Exploring Tcl internals from script - Part II

Published , updated

A previous blog post described the representation command and its use for introspecting Tcl's internal structures for storing data. I promised a follow-up post that talked about Tcl's compiled byte code and the disassemble command for inspecting it. Well, only two years later, here is that post as promised.

(read more)

Exploring Tcl internals from script - Part I

Published , updated

Tcl has some commands that are undocumented because they are liable to change, or even be removed, at any time, even in a patch release. Nevertheless, these commands can be very useful in exploring and understanding the inner workings of Tcl and in some cases, dealing with issues related to performance or interaction with external systems like COM on Windows.

(read more)

Introduction to Tcl Database Connectivity

Published , updated

Tcl 8.6 shipped with the Tcl Database Connectivity (TDBC) API for accessing disparate SQL database implementations in a standard manner. I happened to need it for the first time recently and collected my notes into an introductory article for the benefit of those who, like me, prefer to be spoon fed.

(read more)

Hotkeys on Demand

Published , updated

There is no shortage of hotkey programs for Windows, many of them of high quality. And of course Windows itself allows you to define hotkeys. However, a hotkey program in Tcl is not only very simple to write, it offers the full flexibility and power of Tcl behind it. Meaning what exactly? Read on.

(read more)

Playing God on Windows

Published , updated

There are times during software development when you want to run in interactive mode with maximum privileges on a system, be God as it were. One might think running as Administrator would do it but it doesn't. To be truly omnipotent on Windows, you have to run under the LocalSystem account[1]. It is easy enough with Tcl and this post shows you how. As a side bonus, it also describes how to inject processes into the interactive user's desktop to run under the user's account as well.

(read more)