473,230 Members | 1,743 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,230 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 1655
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.