LocalSymbol["name"]
represents a symbol whose value is persistently stored in the local file system.
LocalSymbol[obj]
represents a persistent symbol corresponding to the local object obj.
LocalSymbol
LocalSymbol["name"]
represents a symbol whose value is persistently stored in the local file system.
LocalSymbol[obj]
represents a persistent symbol corresponding to the local object obj.
Details
- Values can be assigned using LocalSymbol[name]=val or LocalSymbol[name]:=val.
- LocalSymbol[name] evaluates to give the value assigned for LocalSymbol[name].
- If no value has ever been assigned, LocalSymbol[name] does not exist and returns unevaluated. »
- Values of local symbols are stored in local objects.
- LocalSymbol["name"] by default references a local object with the specified name within the directory $LocalSymbolBase.
- LocalSymbol["name",base] references a local object relative to the specified base.
- Local symbols can be shared between users if appropriate permissions are set on the underlying file system objects.
- In LocalSymbol["name"], "name" can be any string.
- LocalSymbol[File["path"]] and LocalSymbol[relpath,File["path"]] are also supported.
- Local symbols can be removed with Remove.
Examples
open all close allBasic Examples (1)
Scope (6)
Local symbols can be assigned delayed values:
LocalSymbol["rand"] := RandomReal[]Table[LocalSymbol["rand"], {5}]Local symbols that have not been assigned remain unevaluated:
LocalSymbol["undefined symbol"]ValueQ[LocalSymbol[…]] checks whether a local symbol has an assigned value:
ValueQ[LocalSymbol["undefined symbol"]]LocalSymbol["defined symbol"] = "value";ValueQ[LocalSymbol["defined symbol"]]LocalObjects can be used to list all existing local symbols:
LocalObjects[$LocalSymbolBase]Local symbols can be removed with Remove:
LocalSymbol["mysym"] = 17Remove[LocalSymbol["mysym"]]LocalSymbol["mysym"]Local symbols work with reassignment functions such as Increment:
LocalSymbol["n"] = 0;LocalSymbol["n"]++LocalSymbol["n"] *= 2--LocalSymbol["n"]Local symbols work with reassignment functions such as AppendTo:
LocalSymbol["list"] = {};AppendTo[LocalSymbol["list"], 1]PrependTo[LocalSymbol["list"], -1]Generalizations & Extensions (3)
Local symbols can be saved to any file:
LocalSymbol["/tmp/testsym"] = 42FileType["/tmp/testsym"]The directory where a symbol should be saved can be given as the second argument:
mybase = "/tmp/symbols";LocalSymbol["sym1", mybase] = 17Paths can also be specified with File:
LocalSymbol[File["/tmp/testsym"]] = 42LocalSymbol["sym1", File["/tmp/symbols"]] = 17Applications (1)
Properties & Relations (5)
Local symbols are stored in local objects, so they can be accessed using LocalObject:
LocalSymbol["sym1"] := RandomReal[]obj = LocalObject["sym1", $LocalSymbolBase]Get[obj]By default, local symbols are saved to a subdirectory of $LocalBase:
{$LocalBase, $LocalSymbolBase}CloudSymbol provides for symbols in cloud storage:
CloudSymbol["cs"] = 10!Use a local symbol as a lock to synchronize access to a shared resource, such as a file:
ParallelEvaluate[WithLock[LocalSymbol["/tmp/lock"], Put[$KernelID, "/tmp/output"]]]Get["/tmp/output"]Reassignment functions are thread safe and can be used in parallel computing without locking:
LocalSymbol["counter"] = 0;ParallelEvaluate[LocalSymbol["counter"]++]{LocalSymbol["counter"], $KernelCount}Related Guides
Text
Wolfram Research (2015), LocalSymbol, Wolfram Language function, https://reference.wolfram.com/language/ref/LocalSymbol.html (updated 2016).
CMS
Wolfram Language. 2015. "LocalSymbol." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2016. https://reference.wolfram.com/language/ref/LocalSymbol.html.
APA
Wolfram Language. (2015). LocalSymbol. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LocalSymbol.html
BibTeX
@misc{reference.wolfram_2026_localsymbol, author="Wolfram Research", title="{LocalSymbol}", year="2016", howpublished="\url{https://reference.wolfram.com/language/ref/LocalSymbol.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_localsymbol, organization={Wolfram Research}, title={LocalSymbol}, year={2016}, url={https://reference.wolfram.com/language/ref/LocalSymbol.html}, note=[Accessed: 12-June-2026]}