In the bash man page is a section on definitions.
blank A space or tab.
word A sequence of characters considered as a single unit by the shell. Also known as a token.
name A word consisting only of alphanumeric characters and underscores, and beginning with an alphabetic character or an underscore. Also referred to as an identifier.
metacharacter A character that, when unquoted, separates words. One of the following: | & ; ( ) < > space tab
control operator A token that performs a control function. It is one of the following symbols: || & && ; ;; ( ) | |& <newline>
So the underscore is considered along with alphanumeric characters as being part of a "name", while others, such as the hyphen, are not.
By the way, here's a small trick you can use so that the underscore is only inserted if the second variable exists. Of course, it can only be used on shells that support this parameter substitution.
or more consisely: