I had the following code:
set swapDict [fillSwapDict]
set swapDict [mergeSwapDict ${swapDict} ${mergeList}]
set swapList [sortedList ${swapDict}]
displayList ${swapList} ${end}
Each call does use the data of the call before it. So I thought it is
better to write it like this:
displayList [sortedList [mergeSwapDict [fillSwapDict] ${mergeList}]] ${end}
Which is the 'better' way, or is another way better?
Cecil Westerhof <Cecil@decebal.nl> wrote:
I had the following code:
set swapDict [fillSwapDict]
set swapDict [mergeSwapDict ${swapDict} ${mergeList}]
set swapList [sortedList ${swapDict}]
displayList ${swapList} ${end}
Each call does use the data of the call before it. So I thought it is
better to write it like this:
displayList [sortedList [mergeSwapDict [fillSwapDict] ${mergeList}]] ${end}
Which is the 'better' way, or is another way better?
There isn't. You are slowly moving closer to merely a "stylistic"
issue on the order of whether this:
if (...) {
...
}
or this
if (...)
{
...
}
Arrangement of the openbrace for a C if clause is the "better way".
The second is more LISP like, and avoids having to allocate, and
ultimately destroy, three variables. But you will find people who
argue with convincing reasons why either is 'better' than the other.
Use whichever you prefer, and don't fret over it. Myself I use the
LISP like layout mostly, but will use the tempvar version on occasion
(and esp. if one of the tempvar version can avoid processing the same
data into the same result two or more times).
Cecil Westerhof <Cecil@decebal.nl> wrote:
I had the following code:
set swapDict [fillSwapDict]
set swapDict [mergeSwapDict ${swapDict} ${mergeList}]
set swapList [sortedList ${swapDict}]
displayList ${swapList} ${end}
Each call does use the data of the call before it. So I thought it is better to write it like this:
displayList [sortedList [mergeSwapDict [fillSwapDict] ${mergeList}]] ${end}
Which is the 'better' way, or is another way better?
There isn't. You are slowly moving closer to merely a "stylistic"
issue on the order of whether this:
if (...) {
...
}
or this
if (...)
{
...
}
Arrangement of the openbrace for a C if clause is the "better way".
The second is more LISP like, and avoids having to allocate, and
ultimately destroy, three variables. But you will find people who
argue with convincing reasons why either is 'better' than the other.
Use whichever you prefer, and don't fret over it. Myself I use the
LISP like layout mostly, but will use the tempvar version on occasion
(and esp. if one of the tempvar version can avoid processing the same
data into the same result two or more times).
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).
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).
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 493 |
Nodes: | 16 (2 / 14) |
Uptime: | 179:12:51 |
Calls: | 9,705 |
Calls today: | 5 |
Files: | 13,736 |
Messages: | 6,179,245 |