Re: Why C dont allow the name of a variable start with a digit?




"Jason20005" <jason20005@xxxxxxxxx> wrote in message
news:79d0b2ff-cd84-4121-b418-f219c086db98@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Dear all,

Why C and some of other languages dont allow the name of a variable
start with a digit?

It's been explained there could be ambiguity between integer constants and
variables.

It might have been feasible where there was no ambiguity (so 0XABC must be a
constant, but 0XABG must an identifier), but it's unsatisfactory. Some other
way of distinguishing constants and identifiers would be needed, and this
would offset some advantage of starting with a digit.

More useful (to me anyway) would have been the ability to use $ in an
identifier (available on some Cs but not standard). Then it could have been
used in place of _, which is difficult to see and can be confused with __
and ___.

--
Bart


.



Relevant Pages

  • Re: problem with loop
    ... as a predefined identifier is as a property of form controls. ... There's no ambiguity for the browser. ... I find MiniTrue useful for viewing/searching/altering files, ...
    (comp.lang.javascript)
  • Re: My last post of the decade here
    ... no ambiguity over whether or not the two digit year abbreviation is ... referring to the day or month. ...
    (rec.arts.sf.written)
  • Re: Parsing C#-like generics
    ... a LessThan in it because it believes that to be a incomplete type list ... You can then use the IDENT and PARAMETERIZED_IDENT tokens in various ... parameterization of an identifier not have intervening whitespace. ... resolving the ambiguity. ...
    (comp.compilers)
  • [OT] Re: pet care
    ... even if it isn't widely used when communicating with people. ... representation, to zeroize ambiguity. ... digit year does not, in general, remove ambiguity between month/day. ...
    (rec.games.roguelike.nethack)
  • Creating a unique ID number based on date and time
    ... account and the same date and this creates duplicates in the ID number. ... While this could work for my identifier, I would prefer just a 5 or 6 digit ... Prev by Date: ...
    (microsoft.public.excel.programming)