Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 15 down vote accepted

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

share|improve this answer
    
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? –  QuantumDot Feb 19 '13 at 3:49
3  
@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. –  rm -rf Feb 19 '13 at 4:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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