I have posted several questions ultimately involving various aspects of robustness, that have arisen in the context of other questions in risk of clouding the main point of the question in each case. I thought it would be appropriate to have a centralised discussion here about what needs to be taken into account to achieve robustness and what sort of things one can do early on to minimise the pain of upgrading one's own code later on.
There was a recent discussion about backward compatibility here where some mixed emotions were being expressed about whether or not a certain author was doing the right thing by his users when abandoning backward compatibility, so it's clearly an important topic. It would be good to discuss this topic without opinions of any one author's application of what is considered best practice and limiting ourselves to discussion of the principles themselves.
I'm in the middle of writing a package myself as a fledgling package writer and various issues have arisen basically concerning robustness of code. Does it access globals appropriately, can it be used in any context, or what are reasonable expectations on where it can be used, without breaking?
None of the other suggested questions, that came up when I typed this one in, are focussed on this particular question. I keep coming up with little questions that I want to ask relating to this topic that would get buried as comment questions and would spread the discussion all over the place as separate questions. Hopefully this is considered a worthy meta discussion.
Answers could either be about general principles or particular examples of use, such as: \pgfmathsetlength
can set a variable prefixed with \global
, whereas \pgfmathaddtolength
can not. Is it best practice in the former case, as you must in the latter case, making the value global with
\pgfmathsetlength{\testvar}{0}\global\testvar\testvar
just in case this changes in future? I suppose whatever the argument, that consistent practice has to be an important guide.
etoolbox
and have some kind of prefix in your command naming scheme to help prevent clashes with other packages.ld@
for internal command names; patching macros rather than replacing them outright; using latex constructs rather than the corresponding TeX primitives; avoiding catcode changes. And what about\usepackage
vs.\RequirePackage
, demanding a minimum version for an included package (when necessary), etc., etc.