Nasir
Nasir

Reputation: 1

How should I structure my TCL code?

Im new to TCl-facing some problems learning it.

However I need to know if any one of you have some script or any idea so that I could make my code more structured ie more readable

Upvotes: 0

Views: 348

Answers (3)

Roalt
Roalt

Reputation: 8440

Except for @kostix excellent "advanced" answer, take these basic Tcl beginner tips into account:

  • avoid the global top level for writing your code, pack in into Proc-edures
  • avoid global variables and use namespaces (see answer @kostix)
  • learn about upvar to pass variables by reference
  • read other tcl code examples by other experienced tcl users

Upvotes: 0

TrojanName
TrojanName

Reputation: 5355

This "TCL for Web Nerds" book by Philip Greenspun is very easy to read, and while it's a bit dated, is a great introduction to TCL (especially if you're doing any web programming). I still refer to it occasionally along with the TCL manuals and the Wiki (although to be honest I often the wiki too obscure for many of my needs).

Upvotes: 0

kostix
kostix

Reputation: 55463

Personally I would recommend this and this articles by Will Duquette, if we're talking about "plain" Tcl (that is, not armed with any extensions aimed at better structuring).

You can do object orientation with Tcl, too. Tcl 8.6 will be equipped with a core OO package, but there is a whole lot of readily available OO frameworks. Personally, I've successfully used Snit as a plain Tcl OO system.

Upvotes: 5

Related Questions