Formal Symbols are protected against being assigned values, making them handy for avoiding name collisions for things like fit parameters and pattern matching. Because formal symbols (and others) like \[FormalA] are immediatly replaced with their character (which looks much nicer in the Front End than \[FormalA]), i found it a bit annoying to figure out the best way of finding them. SymbolName[\[FormalA]] returns exactly the same renderred character as the input, though the input is a Symbol and the output a String. Characters[SymbolName[\[FormalA]]] returns again the same thing. Shortcuts for writing these symbols are ([using] (https://reference.wolfram.com/language/tutorial/KeyboardShortcutListing.html.en) Esc
for :
,:$a:
gives \[FormalA]
and $Omega
gives \[FormalOmega]
while :$CapitalXi:
gives \[FormalCapitalXi
.
But I figured out a way to get what looks to be a decently compherhensive list.
The following returns a list of 168 names when run in a fresh kernel in version 14.0. Are there any other symbols which are intended to be used in a similar way?
formalNames=Select[Names["System`*"],StringContainsQ[ToString[FullForm[#]],"\\[Formal"]&]
I would also like to point out that István Zachar's comment on this question appears to be obsolete, at least for the example \[FormalPhi]
. this can be seen by inspecting the following:
Table[{n, ToString[FullForm[n]], Attributes[Evaluate[Symbol[n]]]}, {n,formalNames}]
Noticing that was actually the main reason I posted this question, since it indicates that formal symbols might be safer to use than I originally thought, at least for 14.0. Are others aware of when this changed?
Not only formal symbols have this sometimes irritating tendency to constantly render in a form that is non ASCII i.e. PrintableASCIIQ[string]
is False. See this list of named chracters
Formal*
family has the attributeProtected
(which is what you want if I understand correctly). $\endgroup$