Since everything is an expression in Mathematica, why must a string object be formed by "abc" but not by a String[abc] expression?

You can look at a string's head by:


But you can not produce the same string by String


which, from my point of view, seems inconsistent with the principle that Everything Is an Expression.

However, I noticed that the basic Symbol object, on the other hand, can be formed by something like Symbol["a"].

The same question goes for four number objects (Integer, Real, Rational, and Complex). You can't say an integer 1 by something like Integer[1], can you?

Edit:Rational and Complex can be produced by their respective heads. So The question is valid only for String and two number objects, i.e. Integer and Real.


String and Integer are what I termed "implicit heads" while writing:

Rather than being part of the standard expression itself, at least as I understand it, these implicit heads instead serve the purpose of providing a "type" for pattern matching. (With a pattern _String, _Integer, etc.) The atomic expressions themselves are stored in a low-level format and handled transparently behind the scenes.

Of the heads you list Rational and Complex are exceptions as these are a kind of hybrid head: you can use them to enter data:

{Complex[1, 2], Rational[5, 8]}
{1 + 2 I, 5/8}

Critically you can also match patterns within these heads:

{1 + 2 I, 5/8} /. {Complex[a_, b_] :> foo[a, b], Rational[n_, m_] :> bar[n, m]}
{foo[1, 2], bar[5, 8]}

Nevertheless these expressions are considered "atomic" and they cannot be manipulated other ways that apply to standard expressions:

AtomQ /@ {1 + 2 I, 5/8}
foo @@@ {1 + 2 I, 5/8}
{True, True}

{1 + 2 I, 5/8}
  • 1
    $\begingroup$ I'm sorry for misleadingly including the Rational and Complex. I just got a bit "unconscious" for forgetting that they are not the same case. I have excluded them from my descriptive details to avoid possible misguidance. $\endgroup$
    – Naitree
    Sep 14 '14 at 13:16
  • 1
    $\begingroup$ @Naitree I found them an interesting aspect of the question and took a large portion of my answer to address them. Unless you feel that my answer is inadequate (which the Accept indicates against) I prefer that you restore your question to its original form. $\endgroup$
    – Mr.Wizard
    Sep 14 '14 at 13:42
  • 1
    $\begingroup$ After reading your answer, I thought it might be misleading for other readers to include a stated fact which is actually false. That's the reason I removed them. I will now re-include them for consistency and add additional comments for avoiding misguidance for other readers. $\endgroup$
    – Naitree
    Sep 14 '14 at 13:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.