Tcl coding convention 1. File name convention: _.tcl All characters are lower case. 2. Namespace convention: The first character is upper case. 3. Variable convention: The first character is lower case. Array variable: a_ (optional, can also use regular variable names) List variable: l_ 4. Indentation convention: Two spaces indentation per level. E.g. if {$foo == "bar"} { puts "something happens" } 5. Comment convention Begining of the file ################ # Comments ################ Comments for the whole file #=============== # Comments #=============== Comments for proc and namespace #--------------- # Comments #--------------- Comments in the middle of the proc # Comments Example: util.tcl #!/home/xiaotaow/tcl83/bin/wish ############################################################################# # Util --- The utility procedures for sipc # # Copyright 1999 - 2000 Columbia University # # Creation date: 09/25/2000 # Last modified: 09/25/2000 # Author: Xiaotao Wu ############################################################################# #============================================================================ # Procedures in this file # # proc: # Util::init {} # Util::seconds {day hour minute second} #============================================================================ #---------------------------------------------------------------------------- # Namespace declaration # # namespace: Util #---------------------------------------------------------------------------- namespace eval Util { } #---------------------------------------------------------------------------- # Util::init # # Set the seed for random #---------------------------------------------------------------------------- proc Util::init {} { # Use the srand math function to set the seed for random expr srand([clock seconds]) } #---------------------------------------------------------------------------- # Util::seconds # # Given day, hour, minute and second, return the number of seconds # they represent #---------------------------------------------------------------------------- proc Util::seconds {day hour minute second} { set res [expr $day*86400 + $hour*3600 + $minute*60 + $second] return $res }