[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug #61569] tmac/an.tmac: unnecessary repeating of code
From: |
Dave |
Subject: |
[bug #61569] tmac/an.tmac: unnecessary repeating of code |
Date: |
Fri, 26 Nov 2021 15:58:55 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0 |
Update of bug #61569 (project groff):
Severity: 3 - Normal => 2 - Minor
_______________________________________________________
Follow-up Comment #1:
I haven't looked at an.tmac to see the context, but based on the snippet
posted here, there is no way to avoid code repetition, and choosing which code
to repeat is a judgment call.
Looking at the structure in pseudocode shows this. This snippet amounts to:
if a then b else c
d
if a then e else f
The straightforward way to restructure this to eliminate the repetition of _a_
results instead in repetition of _d_:
if a then
b; d; e
else
c; d; f
Which of these is "better" depends on several factors: the relative complexity
of _a_ and _d_ currently; which of them might become more complex as the code
undergoes future revisions; which part of the code is more significant to the
overall flow (the current code signifies to readers that _d_ is important, as
it's part of the main flow; the rewrite says the test is the most important
thing, and subsumes _d_ inside it); and other factors.
In practice, the straightforward rewrite for this snippet...
. ie \\n[cR] \{\
. pl +1v
. PT
. pl +1v
. sp 1v
. \}
. el \{\
. sp .5i
. PT
. sp |1i
. \}
...is longer by 3 lines, and not appreciably easier to read.
If you had a different rewrite in mind, please post it.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?61569>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/