Function Repository Resource:

ToFullString

Source Notebook

Create a string of the FullForm of an expression with fully qualified symbol names

Contributed by: Richard Hennigan (Wolfram Research)

ResourceFunction["ToFullString"][expr]

gives a string of the FullForm of expr with fully qualified symbol names.

Examples

Basic Examples (1) 

Get a FullForm string of an expression:

In[1]:=
ResourceFunction["ToFullString"][{1, 2, 3}]
Out[1]=

Scope (4) 

Retrieve the ResourceFunction:

In[2]:=
ResourceFunction["ToFullString"]
Out[2]=

Retrieve the ResourceObject:

In[3]:=
ResourceObject["ToFullString"]
Out[3]=

All symbols will have their full context prepended:

In[4]:=
ResourceFunction["ToFullString"][a + b]
Out[4]=

Expressions can be unevaluated:

In[5]:=
ResourceFunction["ToFullString"][Unevaluated[Print[1 + 1]]]
Out[5]=

Generalizations and Extensions (3) 

Normally, strings are created with the current context and context path taken into account:

In[6]:=
expr = x + y;
In[7]:=
ToString[expr, InputForm]
Out[7]=

This can result in the expression being interpreted differently if the context changes:

In[8]:=
Block[{$Context = "MyContext`", $ContextPath = {"MyContext`", "System`"}},
 ToExpression[%]
 ]
Out[8]=
In[9]:=
% === expr
Out[9]=

Using fully qualified symbol names removes any context-related dependency:

In[10]:=
ResourceFunction["ToFullString"][expr]
Out[10]=
In[11]:=
Block[{$Context = "MyContext`", $ContextPath = {"MyContext`", "System`"}},
 ToExpression[%]
 ]
Out[11]=
In[12]:=
% === expr
Out[12]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 1.0.0 – 15 August 2018

Related Resources

License Information