7
$\begingroup$

I have a function with the following input structure:

f[{{a1, n1}, {a2, n2}...}, {i1, i2,...}]

The first argument is a List of Lists, each with exactly two elements, and the second argument is a list of symbols.

So I thought the appropriate SyntaxInformation to provide is

SyntaxInformation[f] = {  "ArgumentsPattern" -> {{{_, _} ...}, {___}}  };

Now let's look at some input examples (in v9.0.1)

Input examples

In the first example, it is correctly able to indicate the missing argument. But in the second example, it is not highlighting the c and h in red (since these lists don't have exactly two arguments).

So, my guess is that SyntaxInformation is unable to recognize patterns that are too deep. Is this correct? If not, what can be done to get the right syntax highlighting?

$\endgroup$
4
$\begingroup$

The documentation says:

enter image description here

Your form is not one of these so it cannot be expected to work. (It would be nice if it did of course.)

I cannot think of a way to get the syntax highlighting you seek, given this apparent limitation, but I will think about it.

$\endgroup$
5
$\begingroup$

I ma not sure if this help or not but you may use SyntaxInformation twice but with two head functions:

SyntaxInformation[f] = {"ArgumentsPattern" -> {_, {___}}};
SyntaxInformation[g] = {"ArgumentsPattern" -> {{_, _} ...}};

enter image description here

$\endgroup$
1
  • $\begingroup$ @Mr.Wizard, Thanks. your (+1) is like (+10) from others:) $\endgroup$ – Basheer Algohi Oct 24 '14 at 21:37

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.