How do I use the ::usage tag to allow the Mathematica v9 front end to know that there are multiple ways to call an overloaded function (a function that can have different number of arguments?

For example, if I sequentially run the two commands

myfunc::usage = "foo[x,y,z] will combine x, y and z for you.";
myfunc::usage = "foo[x,y,z,w] will be even better.";

The second line has overwritten the first and the front end doesn't know about both cases. A built-in example of what I'm talking about is Table which the front-end recognizes as having many different templates.


1 Answer 1


As of Mathematica 9, multiple autocomplete templates are supported and the different templates are delimited by newlines. So for your example, you'll need to define them as:

myfunc::usage = "foo[x,y,z] will combine x, y and z for you.

foo[x,y,z,w] will be even better.";

enter image description here

  • $\begingroup$ Thanks! But, I am now trying to add a third template, and adding yet another line seems not to work. Does having three templates work for you? $\endgroup$
    – QuantumDot
    Feb 19, 2013 at 3:49
  • 4
    $\begingroup$ @QuantumDot Yes it works, but only if it was defined that way initially. If you want to add a new definition, it looks like you'll have to Remove the symbol first (ClearAll doesn't suffice, even though the message definitions are cleared). My guess is that since the template completion is handled by the FrontEnd, it loads this when the function is first defined and remembers it forever and is unaware of later changes to the symbol in the kernel. $\endgroup$
    – rm -rf
    Feb 19, 2013 at 4:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.