({{, (RefLink[LocalSymbol, paclet:ref/LocalSymbol])["name"] 
represents a symbol whose value is persistently stored in the local file system.}, {, (RefLink[LocalSymbol, paclet:ref/LocalSymbol])[obj]
represents a persistent symbol corresponding to the local object obj.}})

OpenersNotesSection(Spacer1)Details

Values can be assigned using (RefLink[LocalSymbol, paclet:ref/LocalSymbol])[name]=val or (RefLink[LocalSymbol, paclet:ref/LocalSymbol])[name]:=val.

(RefLink[LocalSymbol, paclet:ref/LocalSymbol])[name] evaluates to give the value assigned for (RefLink[LocalSymbol, paclet:ref/LocalSymbol])[name].

Values of local symbols are stored in local objects.

(RefLink[LocalSymbol, paclet:ref/LocalSymbol])["name"] by default references a local object with the specified name within the directory (RefLink[$LocalSymbolBase, paclet:ref/$LocalSymbolBase]).

(RefLink[LocalSymbol, paclet:ref/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 (RefLink[LocalSymbol, paclet:ref/LocalSymbol])["name"], "name" can be any string.

(RefLink[LocalSymbol, paclet:ref/LocalSymbol])[(RefLink[File, paclet:ref/File])["path"]] and (RefLink[LocalSymbol, paclet:ref/LocalSymbol])[relpath,(RefLink[File, paclet:ref/File])["path"]] are also supported.

Local symbols can be removed with (RefLink[Remove, paclet:ref/Remove]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (13)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Assign a value to a local symbol:

LocalSymbol["x"]=10!;

Retrieve the value:

LocalSymbol["x"]

OpenersExampleSection1(Spacer1)Scope  (4)

Local symbols can be assigned delayed values:

LocalSymbol["rand"]:=Random[]

Table[LocalSymbol["rand"],{5}]

Local symbols that have not been assigned remain unevaluated:

LocalSymbol["undefined symbol"]

(RefLink[LocalObjects, paclet:ref/LocalObjects]) can be used to list all existing local symbols:

LocalObjects[$LocalSymbolBase]

Local symbols can be removed with (RefLink[Remove, paclet:ref/Remove]):

LocalSymbol["mysym"]=17

Remove[LocalSymbol["mysym"]]

LocalSymbol["mysym"]

OpenersExampleSection2(Spacer1)Generalizations & Extensions  (3)

Local symbols can be saved to any file:

LocalSymbol["/tmp/testsym"]=42

FileType["/tmp/testsym"]

The directory where a symbol should be saved can be given as the second argument:

mybase="/tmp/symbols";

LocalSymbol["sym1",mybase]=17

Paths can also be specified with (RefLink[File, paclet:ref/File]):

LocalSymbol[File["/tmp/testsym"]]=42

LocalSymbol["sym1",File["/tmp/symbols"]]=17

OpenersExampleSection4(Spacer1)Applications  (1)

Local symbols can be used to remember values across a kernel restart:

LocalSymbol["rememberme"]=17;

Quit[]

LocalSymbol["rememberme"]

OpenersExampleSection5(Spacer1)Properties & Relations  (3)

Local symbols are stored in local objects, so they can be accessed using (RefLink[LocalObject, paclet:ref/LocalObject]):

LocalSymbol["sym1"]:=Random[]

obj=LocalObject["sym1",$LocalSymbolBase]

Get[obj]

By default, local symbols are saved to a subdirectory of (RefLink[$LocalBase, paclet:ref/$LocalBase]):

{$LocalBase,$LocalSymbolBase}

(RefLink[CloudSymbol, paclet:ref/CloudSymbol]) provides for symbols in cloud storage:

CloudSymbol["cs"]=10!

OpenersExampleSection6(Spacer1)Possible Issues  (1)

Local symbols cannot be assigned subvalues or other special values:

LocalSymbol["f"][x_]:=x^2

Values of local symbols are not stored like other symbols:

OwnValues[LocalSymbol["x"]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[LocalObject, paclet:ref/LocalObject])  ▪  (RefLink[$LocalSymbolBase, paclet:ref/$LocalSymbolBase])  ▪  (RefLink[LocalObjects, paclet:ref/LocalObjects])  ▪  (RefLink[Symbol, paclet:ref/Symbol])  ▪  (RefLink[WolframLanguageData, paclet:ref/WolframLanguageData])  ▪  (RefLink[CloudSymbol, paclet:ref/CloudSymbol])  ▪  (RefLink[Remove, paclet:ref/Remove])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Local Objects, paclet:guide/LocalObjects])}, {▪(RefLinkPlain[Persistent Storage, paclet:guide/PersistentStorage])}, {▪(RefLinkPlain[File Operations, paclet:guide/FileOperations])}})}})