It is common in many packages, as well as system symbols, that the same message can be issued by several functions. Here's an example:
One mechanism that can be used for this is to define the message only once, and attach it to the
General symbol. This is how the
infy messages works as well.
infy can appear to come from any symbol:
When writing a custom package, it might not be the best idea to do this though because of the risk of message conflicts. Two packages might attach the same message identifier to
General, so the one that's loaded last will overwrite the previous one. In fact, looking at the some standard packages (e.g. CUDALink), they do not attach messages to
General even when the same message can be issued by several functions. Looking at the source code of the package, CUDALink uses a helper function to attach the same message text to several symbols in one go.
The question: What is the best way to proceed when several functions need to be able to issue the same message, and indicate that it is coming from them? What do you use in your own packages?
What's important for me is minimizing the risk of conflict with other packages and the simplicity of implementation.