Version 2 of Paragraphing

Updated 2003-11-18 10:23:58

if 0 {Richard Suchenwirth 2003-11-18 - By "paragraphing" I understand assigning blocks of code ("paragraphs") to a variable, and building up the control flow by referencing these paragraphs, which makes long open brace ... close brace blocks smaller. Simple example (find the length of the longest string from a list):}

 proc maxlen args {
     set singleList       {[llength $args]==1}
     set expandSingleList {set args [lindex $args 0]}

     if $singleList $expandSingleList

     set res [string length [lindex $args 0]]
     set findLongest {
         set l2 [string length $i]
         if {$l2 > $res} {set res $l2}
     }
     foreach i [lrange $args 1 end] $findLongest
     set res
 }

if 0 {Like so often, I'm not sure how useful this is, but it certainly is not possible in C (well, one could, with preprocessor macros) or a number of other languages...


Arts and crafts of Tcl-Tk programming }