DefineOptions
DefineOptions[function,Options:>ops,SharedOptions:>sharedOps]⟹Null
sets the Options for function and saves metadata about the options for later usage.
Details
- The order of input rules does not matter.
- Only one of Options/SharedOptions is required.
-
AllowNullPattern AllowNull's value `1` must match BooleanP. Please change AllowNull's value. BadPattern Options for `1` marked as IndexMatching, or to which other options IndexMatch, must use a single call to ListableP to define their pattern. Check `2` CategoryPattern Category's value `1` must match _String. Please change Category's value. DescriptionPattern Description's value `1` must match _String. Please change Description's value. Duplicate Unable to define options for `1`. Multiple options defined with the same names: `2`. Format Unable to define options for `1`. Invalid options format. InvalidKey `2` are not valid keys for DefineOptions. You may only use Options or SharedOptions. InvalidKeys The following keys were used in an list of rules to define an option and are invalid `1`. Only {OptionName,Default,AllowNull,Description,ResolutionDescription,Category,IndexMatchingInput,IndexMatching,Expandable,Pattern,SingletonPattern,Widget,Pooled} are valid keys. Please remove these invalid keys. InvalidWidget A widget `1` was specified that does not pass ValidWidgetQ. Please reformat this widget so that it is valid. MissingOptions Failure to copy options from `2` to `3`. Make sure `1` exist as options for `2` when defining options for `3`. MissingRequiredKeys The following keys, `1`, are required to define an option but are missing. Please include these required keys in the options definition `2`. NoOptions Failure to copy options from `1` to `2`. No options found for `1` when defining options for `2`. OptionNamePattern OptionName's value `1` must match _Symbol. Please change OptionName's value. PatternXorWidget One and only one of the keys {Pattern, Widget} can be used to define an option. Please add/remove these keys to satisfy PooledPattern Pooled's value `1` must match BooleanP. Please change Pooled's value. SystemSymbol Cannot define options for Mathematica symbol `1`. UnableToFindPrimitiveHead Unable to find option information about the primitive, `1`, from the primitive set, `2`. Please make sure that DefinePrimitiveSet[...] was called on this primitive set. XorIndexMatchingInputAndParent Exactly one of IndexMatchingInput and IndexMatchingParent must be set for each IndexMatching block in the options. Please include only one of these keys in order to define a valid index matching options block.
Input
Messages
Examples
Basic Examples (4)
Additional Examples (11)
Use two separate IndexMatching[...] blocks:
Options override SharedOptions:
Use option set in line with other options:
Option set can be overwritten by explicity listed options:
Explicitly defined options always take precedence over option sets. Option sets take precedence over shared options. After than any duplicated options from option sets or shared options are deleted (no duplicates are allowed in explictly defined options):
Define options as index-matching to inputs:
Protected symbols are unprotected and re-protected:
Unprotected symbols stay unprotected:
Options defined for the symbol take precedence over shared options: