473,387 Members | 1,440 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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

Dear all,

Why C and some of other languages dont allow the name of a variable
start with a digit?
Apr 11 '08 #1
6 1663
Chris McDonald said:

<snip>
>
The question was actually about *starting* with a digit,
which doesn't necessarily imply consisting *only* of digits.
Yes, I know, but I figured (correctly, as it turns out) that using an
all-digit example would bring the point home to the OP very quickly.
But what about: long int 42L = 6;
0X0 also springs to mind.

Forgive me - this is supposed to be a non-commercial channel.

0x20.

There - that's better.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Apr 11 '08 #2

"Jason20005" <ja********@gmail.comwrote in message
news:79**********************************@h1g2000p rh.googlegroups.com...
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
Apr 11 '08 #3
On Fri, 11 Apr 2008 10:23:05 +0100, Bartc <bc@freeuk.comwrote:
More useful (to me anyway) would have been the ability to use $ in an
identifier
Indeed. VAX/VMS's DCL allowed dollar-signs, e.g. F$SEVERITY.

--
Martin

Apr 11 '08 #4
Martin wrote:
On Fri, 11 Apr 2008 10:23:05 +0100, Bartc <bc@freeuk.comwrote:
>More useful (to me anyway) would have been the ability to use $ in an
identifier

Indeed. VAX/VMS's DCL allowed dollar-signs, e.g. F$SEVERITY.
Still does allow it. So does VaxC if I recall correctly.

--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Jun 27 '08 #5
On Apr 12, 3:01*pm, Mark McIntyre <markmcint...@spamcop.netwrote:
Martin wrote:
On Fri, 11 Apr 2008 10:23:05 +0100, Bartc <b...@freeuk.comwrote:
More useful (to me anyway) would have been the ability to use $ in an
identifier
Indeed. VAX/VMS's DCL allowed dollar-signs, e.g. F$SEVERITY.

Still does allow it. So does VaxC if I recall correctly.

--

I thought VMS was the actual operating system and that the VAX was the
corresponding hardware. I vaguely remember one of the labs at HP
having FreeBSD running on a VAX.
Jun 27 '08 #6
Mark McIntyre <ma**********@spamcop.netwrites:
Martin wrote:
>On Fri, 11 Apr 2008 10:23:05 +0100, Bartc <bc@freeuk.comwrote:
>>More useful (to me anyway) would have been the ability to use $ in an
identifier

Indeed. VAX/VMS's DCL allowed dollar-signs, e.g. F$SEVERITY.

Still does allow it. So does VaxC if I recall correctly.
Last time I used it, yes.

Whether DCL allows dollar signs isn't particularly relevant; that's
the command language, equivalent to a shell on Unix-like systems. But
the VMS (now OpenVMS) dialect(s) of C does allow dollar signs in
identifiers, used mostly for calling native system routines that have
dollar signs in their names. gcc also supports this extension.

(The two major C compilers for VAX/VMS are VAXC and DECC; the latter
is also supported on Alpha/VMS.)

Of course this is non-standard.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Jun 27 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Ravi Tallury | last post by:
Hi We are having issues with our application, certain portions of it stop responding while the rest of the application is fine. I am attaching the Java Core dump. If someone can let me know what...
10
by: KathyB | last post by:
Hi, I just can't get this quite right. I use the following function to validate a user entry. I need to allow negative numbers including those with decimals (e.g., -.5). The following allows the...
10
by: David Casey | last post by:
I'm working on a program for my C++ class and have it all written and working except for one part. I need to compare two numeric variables to determine decimal accuracy between them. For example:...
4
by: N. Demos | last post by:
Hello, I'm learning ASP.NET, and am having a strange problem with some example code from the book I'm using. The code increments and displays the value stored in a session variable when the "Add"...
15
by: Claudio Grondi | last post by:
Let's consider a test source code given at the very end of this posting. The question is if Python allows somehow access to the bytes of the representation of a long integer or integer in...
1
by: kellysgirl | last post by:
Step 3 – Add code in the Form’s Load event to select the first radio button: In the Form’s Load event, write code to select the Comma choice in the radio buttons group box. Step 4 – Add code in...
2
by: yahalom | last post by:
I need to do the following. I want a variable ($var1) to be stored in ($var2). This is what I have done: #!/usr/bin/perl @var1 = `cat ~/data.txt`; #this file contains also IPs which I...
11
by: estantep | last post by:
Hello, I am trying to find out an alternate way to brute-force a variable length vector with different variable length contents. int chromossome int max_value_for_each_chromossome
1
by: jlt206 | last post by:
This code <?php include("counter.php")?> on the webpage produces the count number. (function code below) I want to place the current number into a variable $MemberNo or into a FormField to be sent...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.