Message Boards Message Boards

0
|
1401 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Custom function frontend syntax highlighting for arguments and options

When defining function i make use of SyntaxInfromation a lot for front-end highlighting of inputs. I know I can use ArgumentsOptions and CheckArguments to do internal validation of the input. However, I do also like for the front-end to correctly know how many inputs are needed. This works correctly for only non-option arguments and for options when OptionsPattern[] is specified. But when OptionsPattern[] is specified the argument count is not highlighted correctly. An OptionsPattern is defined as a Sequence of rules that the function recognizes but the front-end highlighting does not.

ClearAll[f]
Options[f] = {aaa -> 1, bbb -> 2};
SyntaxInformation[f] = {"ArgumentsPattern" -> {_, _.}};
(*arguments correct but not aware of options*)
{f[], f[x], f[x, y], f[a, y, z], f[x, y, z, w]};
f[x, y, aab -> 2, aaa -> 3, bba -> 4];

enter image description here

ClearAll[f]
Options[f] = {aaa -> 1, bbb -> 2};
SyntaxInformation[f] = {"ArgumentsPattern" -> {_, _., OptionsPattern[f]}};
(*arguremnts not correct but aware of options*)
{f[], f[x], f[x, y], f[x, y, z], f[x, y, z, w]};
f[x, y, aab -> 2, aaa -> 3, bba -> 4];

enter image description here

Is this intended or am I doing something wrong?

POSTED BY: Martijn Froeling
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract