[thelist] What's the reasoning behind not starting IDs with a number?

liorean liorean at gmail.com
Thu Jan 11 08:42:48 CST 2007

On 11/01/07, Matt Warden <mwarden at gmail.com> wrote:
> I'm pretty sure he's asking *why* this is part of the spec. After all,
> there must be a reason.
> I figure they're trying not to clash with programming languages which
> might automatically create variables based on ID or NAME. Most
> programming languages do not allow variables to begin with a number.
> Now, why do programming languages not allow this? Don't know.

The same reason 1e2 is the number 100 and not the identifier '1e2'.
The same reason 1.2 is the number 1.2 and not the property '2' of the
object '1'. The same reason 0xd is the number 13 and not the
identifier '0xD'... and I could go on... Because numbers are
fundamental data types in virtually all programming or data languages,
and anything less that totally disallowing initial digits in
identifiers would make for a pain for debugging and implementing, and
there's no intuitive way to differentiate when they are identifiers
and when they are numbers, so it would make for much more bugs and
thus loss of programmer, QA, CR and PR manpower for dealing with
actual bugs. Also there's quite some legacy. CSS, JavaScript, all
server side languages I can think of, and most other languages that
might handle HTML and XML identifiers have clear breaks between
numbers and identifiers or strings in their own parsers.
David "liorean" Andersson

More information about the thelist mailing list