Open maxitg opened 4 years ago
For usage messages, I should mention SetUsage
in GeneralUtilities
, which introduces a rich language of usage messages that actually exceeds what is possible in ordinary Wolfram Language. To see how it "demo itself", try ?SetUsage'
:
It uses a superset of the conventioned used by Mathematica's own, strange "docutools" system.
Yes, that's a lot better than the current system: https://github.com/maxitg/SetReplace/blob/26047a96206b32b8acbf2075328471fee9073513/Kernel/GeneralizedGridGraph.m#L7-L10
The problem
It seems like there is a lot that can be automated about Wolfram Language syntax checking, exception handling, etc. For example, take a look at HypergraphUnificationsPlot.
A lot of that file does not seem necessary. Specifically, https://github.com/maxitg/SetReplace/blob/26047a96206b32b8acbf2075328471fee9073513/Kernel/HypergraphUnificationsPlot.m#L11 can be inferred from the function definition.
https://github.com/maxitg/SetReplace/blob/26047a96206b32b8acbf2075328471fee9073513/Kernel/HypergraphUnificationsPlot.m#L17-L19 is essentially the same for all functions.
https://github.com/maxitg/SetReplace/blob/26047a96206b32b8acbf2075328471fee9073513/Kernel/HypergraphUnificationsPlot.m#L21-L22 can be inferred from the function definition as well.
In fact, ideally, all we would need to do in that file is this:
If the pattern in the definition above did not match, it should know that an error message should be printed. At this point, it can go through the arguments, see which one did not match, and print a message about it based on its position, the original function call, and the test function (we can have a map from test functions to messages).
The tests for most cases of invalid arguments would not be necessary as well, because we can just test
definePublicSymbol
once with many different argument patterns.