# Why does the Symbol stringification operation appear to work with only single argument strings? [closed]

I'm trying to label my symbolic object's using Symbol

Works as expected

Symbol["M" <> ToString[5]]


Output

M5


When I try do two variable indexing I get a result that doesn't work

Symbol[StringJoin["M", ToString[5], "_", ToString[12]]]
Symbol["M" <> ToString[5] <> "_" <> ToString[12]]


Output

Symbol["M5_12"]
Symbol["M5_12"]


So, the input to all three cases appears to be strings:

Head @ ("M" <> ToString[5])
Head @ (StringJoin["M", ToString[5], "_", ToString[12]])
Head @ ("M" <> ToString[5] <> "_" <> ToString[12])


Output

String
String
String


I'm confused.

Why does Symbol appear to have different output for the same class of input?

• Well, darn, ain't it hard to find an explicit definition of a valid symbol name. The documentation for Symbol may be as close as one can get: "The string "name" in Symbol["name"] must be an appropriate name for a symbol. It can contain any letters, letter-like forms, or digits, but cannot start with a digit." The clue is "letter-like form"; and an underscore is not a letter-like form but stands for Blank[]. Other syntactic marks (+, :, =, etc.) are also not letter-like forms. – Michael E2 Nov 26 '18 at 1:39
• Better user experience would trigger an explicit error. – Mikhail Nov 26 '18 at 1:42
• I get an error when I execute Symbol["M5_12"]: i.stack.imgur.com/rPj7i.png – Michael E2 Nov 26 '18 at 1:43
• The error message from this input very clearly states that that this is not a valid symbol name. I do not understand what your confusion is. – Jason B. Nov 26 '18 at 2:18
• I don't see that error. Pehraps my version is different. I'll check when I get home. – Mikhail Nov 26 '18 at 2:26

Symbol[StringJoin["M", ToString[5], "x", ToString[12]]]

• _ or Blank cannot appear in a variable name since it is a pattern object that can stand for any Wolfram Language expression. – Bob Hanlon Nov 26 '18 at 1:45