InitializationValue
✖
InitializationValue
represents the settable persistent value with which the symbol sym will be initialized.
represents the settable initialization value for the symbol with the specified complete name.
specifies the persistence locations to search for a possible initialization value.
Details and Options



- InitializationValue[sym] is equivalent to InitializationValue[sym,$PersistencePath].
- InitializationValue[sym]=value sets an initialization value for sym.
- InitializationValue[sym]=value is equivalent to InitializationValue[sym,$PersistenceBase]=value.
- The following options can be given:
-
EvaluationEnvironment $EvaluationEnvironment the environment in which the value should be used MergingFunction Automatic the function applied to the list of values found ValuePreprocessingFunction Identity the function applied to new values to be assigned ExpirationDate None when the value should expire PersistenceTime None how long the value should persist - In InitializationValue[sym,loc], possible forms for the persistence location loc include:
-
PersistenceLocation["type"] "Local", "Cloud", "FrontEndSession", etc. locations "type" equivalent to PersistenceLocation["type"] PersistenceLocation["type","base"] location with a particular base (directory etc.) "type""base" equivalent to PersistenceLocation["type","base"] - Supported location types include:
-
"KernelSession" current invocation of the Wolfram Language kernel "FrontEndSession" current invocation of the Wolfram Notebook front end "Local" local to a computer, based on user home directory "LocalShared" local to a computer, based on $BaseDirectory "Cloud" in the cloud defined by the current $CloudBase "Installation" installation defaults - InitializationValue[sym]=$NoValue specifies that the symbol sym should be unset on initialization.
- The value returned from InitializationValue[sym,{loc1,loc2,…}] is obtained by applying the given merging function to the list of values {InitializationValue[sym,loc1],InitializationValue[sym,loc2],…}. The default merging function is First.
- If no explicit setting for MergingFunction is given, the setting to use is looked up on $PersistencePath.
- Before a new value is assigned in InitializationValue[sym]=value, any specified value preprocessing function is applied to value before the value is assigned.
- If the preprocessing function returns $Failed, the assignment is not performed.
- If no explicit setting for ValuePreprocessingFunction is given, the setting to use is looked up on $PersistencePath.
- An expired initialization value is treated as nonexistent, and the underlying persistent object may be removed.
- Initialization values can be removed with Remove. Remove[InitializationValue[name]] is equivalent to Remove[InitializationValue[name,$PersistenceBase]].
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Set a value to be evaluated every time the kernel starts:

https://wolfram.com/xid/0dqvucvws2y-siknch

Set an initialization value for a variable:

https://wolfram.com/xid/0dqvucvws2y-gcmmbn

Get any initialization value defined:

https://wolfram.com/xid/0dqvucvws2y-e3lemv

Initialize the variable from the persistent value in the current kernel session:

https://wolfram.com/xid/0dqvucvws2y-ehnzv9


https://wolfram.com/xid/0dqvucvws2y-67eynj

https://wolfram.com/xid/0dqvucvws2y-t67nui

Remove the initialization value:

https://wolfram.com/xid/0dqvucvws2y-uesylc
Scope (1)Survey of the scope of standard use cases
Set an initialization value in the default persistence location:

https://wolfram.com/xid/0dqvucvws2y-onnj1q


https://wolfram.com/xid/0dqvucvws2y-2whx5z
Set an initialization value in the "KernelSession" persistence location:

https://wolfram.com/xid/0dqvucvws2y-f7lg0c
The first value found in $PersistencePath is used:

https://wolfram.com/xid/0dqvucvws2y-v0g1tw


https://wolfram.com/xid/0dqvucvws2y-r3y0n0

Find all initialization values ever defined:

https://wolfram.com/xid/0dqvucvws2y-n9syjj

Generalizations & Extensions (1)Generalized and extended use cases
Set an initialization value for parallel subkernels:

https://wolfram.com/xid/0dqvucvws2y-ylxt4z
All newly launched parallel subkernels use the given value:

https://wolfram.com/xid/0dqvucvws2y-4g0a51

https://wolfram.com/xid/0dqvucvws2y-touiop

Remove the initialization value:

https://wolfram.com/xid/0dqvucvws2y-yyzzee
Options (5)Common values & functionality for each option
EvaluationEnvironment (1)
MergingFunction (1)
Give a default value for a variable:

https://wolfram.com/xid/0dqvucvws2y-121o5v
Set a custom merging function for initialization values of the variable:

https://wolfram.com/xid/0dqvucvws2y-umbtzu


https://wolfram.com/xid/0dqvucvws2y-0bwdsm
Specify initialization values at different persistence locations:

https://wolfram.com/xid/0dqvucvws2y-yld5kp
The custom merging function is used to return the list of all values on $PersistencePath:

https://wolfram.com/xid/0dqvucvws2y-imt46o

Use a different merging function for a particular value lookup:

https://wolfram.com/xid/0dqvucvws2y-5q2vie

ValuePreprocessingFunction (1)
Give a default value for an initialization value:

https://wolfram.com/xid/0dqvucvws2y-qucy5n
Set a a custom value preprocessing function that accepts only integers:

https://wolfram.com/xid/0dqvucvws2y-24izaz

https://wolfram.com/xid/0dqvucvws2y-8mk16z


https://wolfram.com/xid/0dqvucvws2y-5v61ks
Assign an integer at any persistence location:

https://wolfram.com/xid/0dqvucvws2y-8h67b2
Assigning anything else generates an error, and the assignment is not performed:

https://wolfram.com/xid/0dqvucvws2y-y88h52

PersistenceTime (1)
Applications (2)Sample problems that can be solved with this function
Override the default persistence base in all kernels started under the current front end session:

https://wolfram.com/xid/0dqvucvws2y-i1dxhj

https://wolfram.com/xid/0dqvucvws2y-crq4g9

https://wolfram.com/xid/0dqvucvws2y-4vqztk

Set a value for $GeoLocation tied to your login account:

https://wolfram.com/xid/0dqvucvws2y-xb4a07
Properties & Relations (2)Properties of the function, and connections to other functions
Initialization values are stored in persistent objects:

https://wolfram.com/xid/0dqvucvws2y-9soiuh

https://wolfram.com/xid/0dqvucvws2y-nosrbc

List the existing initialization values in all editable persistence locations:

https://wolfram.com/xid/0dqvucvws2y-wgtwqg


https://wolfram.com/xid/0dqvucvws2y-jhwzrb
Possible Issues (1)Common pitfalls and unexpected behavior
Create two initialization values for a symbol in different locations:

https://wolfram.com/xid/0dqvucvws2y-dhsrmc
Remove by default removes only the value in the location given by $PersistenceBase:

https://wolfram.com/xid/0dqvucvws2y-y8e29a

https://wolfram.com/xid/0dqvucvws2y-jdbo4p

Remove all values that might exist anywhere in the locations given by $PersistencePath:

https://wolfram.com/xid/0dqvucvws2y-6iica

https://wolfram.com/xid/0dqvucvws2y-3dvr9p

Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).
Text
Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).
Wolfram Research (2017), InitializationValue, Wolfram Language function, https://reference.wolfram.com/language/ref/InitializationValue.html (updated 2019).
CMS
Wolfram Language. 2017. "InitializationValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/InitializationValue.html.
Wolfram Language. 2017. "InitializationValue." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/InitializationValue.html.
APA
Wolfram Language. (2017). InitializationValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InitializationValue.html
Wolfram Language. (2017). InitializationValue. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/InitializationValue.html
BibTeX
@misc{reference.wolfram_2025_initializationvalue, author="Wolfram Research", title="{InitializationValue}", year="2019", howpublished="\url{https://reference.wolfram.com/language/ref/InitializationValue.html}", note=[Accessed: 07-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_initializationvalue, organization={Wolfram Research}, title={InitializationValue}, year={2019}, url={https://reference.wolfram.com/language/ref/InitializationValue.html}, note=[Accessed: 07-June-2025
]}