Seeing the vast scope of science covered by the Wolfram Language (WL) and the large amount of built-in symbols (functions), I am curious to know which built-in symbols are more close to the root of WL, i.e., they are wired deeper in the kernel and are less easily bypassed by tricks.
For example, when assigning UpValues
the assignment tag should be at level no deeper than 2. If we make an assignment like
Clear[f,g,tag,fg]
tag/:f[g[tag]]:=fg[tag]
a warning message is displaced as
TagSetDelayed::tagpos: "Tag tag in f[g[tag]] is too deep for an assigned rule to be found."
and the evaluation returns $Failed
, because the tag
is at level 3.
However, there are some built-in symbols which are not restricted by the level-2-requirement:
list = {HoldPattern, ReleaseHold, Unevaluated, Evaluate,
Refresh, Activate, IgnoringInactive};
Map[(tag /: f[#[tag]] := #) &, list];
In this code the tag
is at level 3, however all assignments can be made successfully without generating error message.
Even at level 4 there is no error message for some combinations:
Map[(tag /: f[#[[1]]@#[[2]]@tag] := #) &, Tuples[list, 2]]
For example, this assignment is successful,
tag /: f[Evaluate@HoldPattern@tag] := tag
It appears that the built-in symbols in list
are not considered as normal wrapper. Some of these symbols are also less easily bypassed by using tricks like assigning UpValues
, for instance,
tag /: HoldPattern[tag[x_]] := x;
HoldPattern[tag[_]]
which still returns
HoldPattern[tag[_]]
It is reasonable that, out of the thousands of built-in symbols, some of them are more fundamental and the others are built basing on the fundamental ones. Can we find out these fundamental symbols? So we can at least know a bit more about the mystery behind the veil.
Comments
Post a Comment