On 5/7/2022 7:32 AM, Robert Heller wrote:
The only other issue is source code readablity. *Sometimes* you end up with either a really long line (which does not "fit" on your screen, unless you have an insanely large edit windows and/or are using a really small font), or an insanely large number of continue lines (and possibly really large indenting). Sometime breaking up a large and complex expression into subexpressions results in code that is easier to read and understand (and in some cases easier to debug).
Cecil:
I totally agree with Robert, especially with debugging.
I will often go even further and create more specific temporary
variables, since it often results in more self-explanatory code:
set filledDict [fillSwapDict]
set mergedDict [mergeSwapDict ${filledDict} ${mergeList}]
set swapList [sortedList ${mergedDict}]
But the primary reason is that if you create one functional style
statement with nested proc/command calls, it becomes quite difficult to
tell which of the intermediate steps isn't working correctly when the
final result is not as expected.
To that end, with my editor, I can do 4 drag and drop copies of those
variables onto a single line, like so:
filledDict mergedDict swapList mergeList
then a triple click on the line selects the 4 and 1 keystroke launches
an external editor tool where the 4 variables are sent to a tcl program
and returned with this text to replace the 4:
puts "filledDict= |$filledDict| mergedDict= |$mergedDict| ..."
I might then add some newlines to this, or [lsort] them etc.
Given the speed of computers these days, I seldom write more than a few
lines of code before I hit my launch key in the editor which will write
out the file and launch it as the arg to a tclkit. In about 1 second, I
will have a console window in front of me with the output of that puts
right there. A [vwait ::ffff] can work like a breakpoint there as well.
I find that this is far easier and quicker than to navigate to the code
in some sort of single stepping and break-point setting debugging tool.
And when done, I comment them out, and usually right indent the puts
past say column 50 so they're still right there if needed again while
not making the real code hard to see.
I tend to build bottom-up and so I develop small functional procedures
that I can grow and debug independent of the rest of some program. Later
I glue the pieces together after I know they are all working correctly.
Hope this helps.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)