I believe that there are three canonical ways to solve flexible arguments:
- everything goes:
f[x_] , - several forms:
f[{x : p ..}] and f[x:p] , where one calls the other, and - alternation:
f[{x : p ..} | x : p] f[{x : p ..} | x : p] .
The main difference is that you are dealing with the additional complexity of flexible arguments. Everyone can have their own advantages.
The main advantage of something is the simplicity of creating acceptable templates, but this leaves processing internal functions, which increases its complexity. For a good example, see ErrorBarPlots .m . Ultimately, ErrorListPlot relies on the second method, hidden behind the facade of the first method.
A method with multiple forms imposes complexity on the dispatcher when choosing the right alternative. It has the simplest functional form, since one form usually calls another form with the "correct" data layout. The difficulty with this method lies in the exponential growth of the specifications of functions with the number of parameters with alternatives. This can be limited by adopting a hybrid approach, such as that found in ErrorListPlot .
Alternation has the most complex form of the template and may require special processing to extract alternatives similar to anything. In addition, the templates themselves can be more difficult to build, and because of the possibility of additional processing, this method should be used the least often of the three. However, in some cases, as in your code, this method may be the simplest implementation.
source share