is an option for functions such as PersistentSymbol and InitializationValue that specifies a function to apply to a new value that is being assigned.
ValuePreprocessingFunction
is an option for functions such as PersistentSymbol and InitializationValue that specifies a function to apply to a new value that is being assigned.
Details
- When a value is to be assigned with PersistentSymbol["name",…]=value or InitializationValue["name",…]=value, the setting of the ValuePreprocessingFunction option is applied to value; the result is then assigned. If the result is $Failed, no assignment is done.
- The default setting is ValuePreprocessingFunction->Identity, which does not modify the value to be assigned.
- Settings for ValuePreprocessingFunction are typically done for the "Installation" persistence location.
Examples
Basic Examples (1)
Define a value preprocessing function that accepts only integers:
validateInteger[x_] := If[IntegerQ[x], x, $Failed]Set up a default value and the value preprocessing function for a persistent value named "int":
PersistentSymbol["int", "Installation"] = 0;io = PersistentObject["int", "Installation"]io["ValuePreprocessingFunction"] = validateInteger;Assign an integer at any persistence location:
PersistentSymbol["int", "KernelSession"] = 42;Assigning anything else generates an error, and the assignment is not performed:
PersistentSymbol["int", "KernelSession"] = 0.5;PersistentSymbol["int"]See Also
History
Text
Wolfram Research (2017), ValuePreprocessingFunction, Wolfram Language function, https://reference.wolfram.com/language/ref/ValuePreprocessingFunction.html.
CMS
Wolfram Language. 2017. "ValuePreprocessingFunction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ValuePreprocessingFunction.html.
APA
Wolfram Language. (2017). ValuePreprocessingFunction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ValuePreprocessingFunction.html
BibTeX
@misc{reference.wolfram_2026_valuepreprocessingfunction, author="Wolfram Research", title="{ValuePreprocessingFunction}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ValuePreprocessingFunction.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_valuepreprocessingfunction, organization={Wolfram Research}, title={ValuePreprocessingFunction}, year={2017}, url={https://reference.wolfram.com/language/ref/ValuePreprocessingFunction.html}, note=[Accessed: 13-June-2026]}