gives information used to generate syntax coloring and other advisories when f[…] is entered as input.
SyntaxInformation
gives information used to generate syntax coloring and other advisories when f[…] is entered as input.
Details
- SyntaxInformation[f]={"prop1"->data1,"prop2"->data2,…} defines syntax properties propi for f.
- Possible properties include:
-
"ArgumentsPattern" patterns for the sequence of allowed arguments "LocalVariables" type and allowed positions of local variables "ColorEqualSigns" argument positions for which = should be colored - The setting for "ArgumentsPattern" is of the form {patt1,patt2,…}, where the patti can be _, __, ___, _., OptionsPattern[], or {p1,…}.
- If the setting for "ArgumentsPattern" specifies that f takes options, then valid option names are determined from Options[f].
- The setting for "LocalVariables" is of the form {"type",{imin,imax}}. Possible types include "Table", "Solve", "Integrate", "Limit", "Plot", "Manipulate". imin and imax give the minimum and maximum argument positions at which the variables can appear. imax can be Infinity.
- A setting for "LocalVariables" of {"type",{imin,imax},"Lexical"} specifies that local variables that appear inside Dynamic should not be specially colored.
- The setting for "ColorEqualSigns" is of the form {imin,imax}.
Examples
open all close allBasic Examples (2)
Specify that f should take exactly two arguments:
SyntaxInformation[f] = {"ArgumentsPattern" -> {_, _}};{f[], f[x], f[x, y], f[x, y, z], f[x, y, z, w]};Options[f] = {aaa -> 1, bbb -> 2};Specify that f should have two arguments, followed by options:
SyntaxInformation[f] = {"ArgumentsPattern" -> {_, _, OptionsPattern[]}};Inappropriate options are colored red:
f[x, y, aab -> 2, aaa -> 3, bba -> 4];Scope (4)
The first argument of f should be a list of exactly two elements:
SyntaxInformation[f] = {"ArgumentsPattern" -> {{_, _}, _}};{f[{a}, x], f[{a, b}, x], f[{a, b, c}, x]};The first argument is allowed to be an expression such as a symbol, which could evaluate to a list:
{f[a], f[a, x], f[a, x, y]};f can have any number of arguments, but each should be a two-element list:
SyntaxInformation[f] = {"ArgumentsPattern" -> {{_, _}...}};{f[{x, y}, {a, b}], f[{x}, {a, b}, {x, y, z}]};f should allow "Table-like" local iterator specifications at positions 2 through infinity:
SyntaxInformation[f] = {"LocalVariables" -> {"Table", {2, Infinity}}};f[x + y, {x, 0, 1}];f should have one ordinary argument, followed by iterator-type list arguments:
SyntaxInformation[f] = {"LocalVariables" -> {"Table", {2, Infinity}}, "ArgumentsPattern" -> {_, {_, _, _., _.}..}};f[x + y + z, {x, 0, 1}, {y, 0, 1, 2, 3}];See Also
Related Guides
History
Text
Wolfram Research (2007), SyntaxInformation, Wolfram Language function, https://reference.wolfram.com/language/ref/SyntaxInformation.html.
CMS
Wolfram Language. 2007. "SyntaxInformation." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SyntaxInformation.html.
APA
Wolfram Language. (2007). SyntaxInformation. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SyntaxInformation.html
BibTeX
@misc{reference.wolfram_2026_syntaxinformation, author="Wolfram Research", title="{SyntaxInformation}", year="2007", howpublished="\url{https://reference.wolfram.com/language/ref/SyntaxInformation.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_syntaxinformation, organization={Wolfram Research}, title={SyntaxInformation}, year={2007}, url={https://reference.wolfram.com/language/ref/SyntaxInformation.html}, note=[Accessed: 13-June-2026]}