[comp.lang.c] Why are @, `, and $ not used in C?

bengsig@oracle.nl (Bjorn Engsig) (09/18/89)

By mistake, I just typed a define as VALUE@ in stead of VALUE2, and I 
realised that it didn't look like C at all.  A quick glance on my keyboard
shows three characters, @, `, and $ that cannot be used in C outside of
strings.  Is there any historic reason for that?

I know that $ is often allowed in identifiers so that is ruled out, but
couldn't @ and/or ` have been used for something useful.
-- 
Bjorn Engsig, bengsig@oracle.nl, bengsig@oracle.com, mcvax!orcenl!bengsig

ken@gatech.edu (Ken Seefried III) (09/19/89)

In article <509.nlhp3@oracle.nl> bengsig@oracle.nl (Bjorn Engsig) writes:
>
>                                             A quick glance on my keyboard
>shows three characters, @, `, and $ that cannot be used in C outside of
>strings.  Is there any historic reason for that?
>

Well, I'm not sure about @ and `, but I know that there are implimentations
of C that make extensive use of $.  Remembering that all the world is not 
Unix, DEC VMS C and (I think) CDC NOS/VE C both use $ in identifiers.

K&R 1st edition (the One True C ;') implies that this is not legal C on
page 179:

	"An identifier is a sequence of letters and digits;
	the first character must be a letter.  The under-
	score _ counts as a letter."

Though since the use of $ is not specificly prohibited, I guess CDC
and DEC felt it was okay to use them...

Also...I believe the SunOS 3.x C compilers accept $ in identifiers,
but it's been a while...

	...ken seefried iii	...!<anywhere>!gatech!ken
	   ken@gatech.edu

Programmes are the magic spells cast over computers that allow them to 
turn ones input into error messages...

"Low Probability", when properly translated, means "it will happen at the 
most inopportune moment..." -me

afscian@violet.waterloo.edu (Anthony Scian) (09/19/89)

In article <509.nlhp3@oracle.nl> bengsig@oracle.nl (Bjorn Engsig) writes:
>I know that $ is often allowed in identifiers so that is ruled out, but
>couldn't @ and/or ` have been used for something useful.
One compiler used the '@' sign to give a small data model program
on the 8086 an extra 64K. The '@' represented an indirection
based off the ES register instead of DS. I don't recall if '@'
was used instead of '*' like:

	if( p ) {
	    (@p).field = @q;
	}

or Pascal-ish like:

	if( p ) {
	    p@.field = q@;
	}

It was a clever trick for getting an extra 64K before
the days of memory models.
--
Anthony
//// Anthony Scian afscian@violet.uwaterloo.ca afscian@violet.waterloo.edu ////
"I can't believe the news today, I can't close my eyes and make it go away" -U2

rbr4@uhura.cc.rochester.edu (Roland Roberts) (09/19/89)

In article <509.nlhp3@oracle.nl> bengsig@oracle.nl (Bjorn Engsig) writes: 
>...A quick glance on my keyboard shows three characters, @, `, and $
>that cannot be used in C outside of strings.  Is there any historic
>reason for that?

In article <19211@gatech.edu> ken@gatech.UUCP (Ken Seefried III) writes:
>...DEC VMS C and (I think) CDC NOS/VE C both use $ in identifiers....
>Also...I believe the SunOS 3.x C compilers accept $ in identifiers,

The GNU C compiler also accepts $ in identifiers.

roland-- 
Roland Roberts                      BITNET: roberts@uornsrl
  Nuclear Structure Research Lab  INTERNET: rbr4@uhura.cc.rochester.edu
  271 East River Road                 UUCP: rochester!ur-cc!uhura!rbr4
  Rochester, NY  14267                AT&T: (716) 275-8962

cik@l.cc.purdue.edu (Herman Rubin) (09/20/89)

As I understand it, the reason that @ was not used instead of * for
indirection was that @ was the UNIX line kill character.
-- 
Herman Rubin, Dept. of Statistics, Purdue Univ., West Lafayette IN47907
Phone: (317)494-6054
hrubin@l.cc.purdue.edu (Internet, bitnet, UUCP)

dwh@twg-ap.UUCP (Dave Hamaker) (09/21/89)

From article <509.nlhp3@oracle.nl>, by bengsig@oracle.nl (Bjorn Engsig):
> By mistake, I just typed a define as VALUE@ in stead of VALUE2, and I 
> realised that it didn't look like C at all.  A quick glance on my keyboard
> shows three characters, @, `, and $ that cannot be used in C outside of
> strings.  Is there any historic reason for that?
> 
> I know that $ is often allowed in identifiers so that is ruled out, but
> couldn't @ and/or ` have been used for something useful.
> -- 
> Bjorn Engsig, bengsig@oracle.nl, bengsig@oracle.com, mcvax!orcenl!bengsig

I'd guess the non-use of @ is connected with its use as the Unix line-kill
character which has fallen into disuse in these days of CRT terminals (even
though @ is often still the default kill character).  Ironically, the # is
used in C when it had a similar role as the erase editing character; maybe
the preprocessor came second.  ` and $ might have something to do with the
original Ascii having different graphics for ` and _ (up arrow and left
arrow, I think).  _ could have replaced $ use in identifiers and ` may not
have had enough potential use to get added later on (besides the potential
confusion with ').

These are possible historical reasons but they're not authoritive.  Someone
else may know.

-Dave Hamaker
The Wollongong Group
...!amdahl!twg-ap!dwh
dwh@twg.com

marcus@illusion.UUCP (Marcus Hall) (09/22/89)

In article <1596@l.cc.purdue.edu> cik@l.cc.purdue.edu (Herman Rubin) writes:
>
>As I understand it, the reason that @ was not used instead of * for
>indirection was that @ was the UNIX line kill character.

Of course, the '#' character was the erase character and yet it was used for
the pre-processor.  I do agree that the '@' was likely avoided at least
partly for its use as a kill character, however.

There have been some difficult to figure out problems with the '#' character
I have come across.  In particular, there is a debugger that uses pre-processor
like syntax for many operations.  One of the first things that must be done
when starting a debugging session is to build a hashfile.  The directive to
do this is '#hashfile <filename>'.  Well, if you don't have the .profile file
set up the erase character, trying to type this in causes the '#' to disappear
(since it 'erases' the character before it) and thus the debugger doesn't
recognize the command and gives an error message about using a symbol before
things are set up.  Since the input looks (to a human reader) perfectly
correct and not at all like trying to do anything with a variable, it was
difficult to eventually determine what the problem was.

marcus hall

scs@hstbme.mit.edu (Steve Summit) (09/22/89)

An amusing bit of trivia is that pcc (4bsd, at least), among
other heroic efforts at antediluvian backwards compatibility,
still "accepts" (if only so it can reject it) an old BCD constant
syntax involving backquotes:

	$ /lib/ccom
	int x = `1234567` + `8;
	line 1: BCD constant exceeds 6 characters
	line 1: newline in BCD constant
	line 1: gcos BCD constant illegal

bruner@uicsrd.csrd.uiuc.edu (John Bruner) (09/22/89)

>>As I understand it, the reason that @ was not used instead of * for
>>indirection was that @ was the UNIX line kill character.
>
>Of course, the '#' character was the erase character and yet it was used for
>the pre-processor.  I do agree that the '@' was likely avoided at least
>partly for its use as a kill character, however.

Early C programs did not rely so heavily upon the preprocessor.  Even as
late as the Sixth Edition (PDP-11) release, there was no "/usr/include",
and "cc" (and the old "fc" Fortran) invoked the preprocessor only if the
first character in the source file was a pound-sign.  Hence, the
overloading of the '#' erase character was not so onerous.

The dollar-sign was not available for use in defining identifier names
because it was (and still is on some machines such as a UNIX VAX) used 
to denote immediate operands in the assembler.  The characters chosen
by DEC which the UNIX assembler did not use for immediate and indirect
operand formats were, of course, '#' and '@'.
John Bruner	Center for Supercomputing R&D, University of Illinois
	bruner@uicsrd.csrd.uiuc.edu	(217) 244-4476	

shankar@hpclscu.HP.COM (Shankar Unni) (09/23/89)

> As I understand it, the reason that @ was not used instead of * for
> indirection was that @ was the UNIX line kill character.

Hmmm? How about "#" (the "classic" erase character)?
----
Shankar.

ken@aiai.ed.ac.uk (Ken Johnson) (09/24/89)

> Why are @, `, and $ not used in C?

I understand that 3 free Ascii codes were left so as to allow C to be
ported into a language with a 29-letter alphabet.  Which one I can't
imagine. 


-- 
Ken Johnson, AI Applications Institute, 80 South Bridge, Edinburgh EH1 1HN
E-mail ken@aiai.ed.ac.uk, phone 031-225 4464 extension 212
`I have read your article, Mr.  Johnson, and I am no wiser than when I
started.' -- `Possibly not, sir, but far better informed.'

gwyn@smoke.BRL.MIL (Doug Gwyn) (09/24/89)

In article <928@skye.ed.ac.uk> ken@aiai.UUCP (Ken Johnson) writes:
-> Why are @, `, and $ not used in C?
-I understand that 3 free Ascii codes were left so as to allow C to be
-ported into a language with a 29-letter alphabet.  Which one I can't
-imagine. 

Me neither.  How do these stories get started?  (It's nowhere near
the first of April.)

meissner@tiktok.dg.com (Michael Meissner) (09/25/89)

In article <364@twg-ap.UUCP> dwh@twg-ap.UUCP (Dave Hamaker) writes:
| From article <509.nlhp3@oracle.nl>, by bengsig@oracle.nl (Bjorn Engsig):
| > By mistake, I just typed a define as VALUE@ in stead of VALUE2, and I 
| > realised that it didn't look like C at all.  A quick glance on my keyboard
| > shows three characters, @, `, and $ that cannot be used in C outside of
| > strings.  Is there any historic reason for that?
| > 
| > I know that $ is often allowed in identifiers so that is ruled out, but
| > couldn't @ and/or ` have been used for something useful.
| > -- 
| > Bjorn Engsig, bengsig@oracle.nl, bengsig@oracle.com, mcvax!orcenl!bengsig

First of all, it's amusing that a European, rather than a resident of
the United States is asking why all of the national language
characters ($, @, #, et. al.) aren't used.

| I'd guess the non-use of @ is connected with its use as the Unix line-kill
| character which has fallen into disuse in these days of CRT terminals (even
| though @ is often still the default kill character).  Ironically, the # is
| used in C when it had a similar role as the erase editing character; maybe
| the preprocessor came second.  ` and $ might have something to do with the
| original Ascii having different graphics for ` and _ (up arrow and left
| arrow, I think).  _ could have replaced $ use in identifiers and ` may not
| have had enough potential use to get added later on (besides the potential
| confusion with ').

It's been at least 10 years since I used a version 6 PDP-11, but I
seem to recall dimly that the backspace character lost it's special
meaning when it was on the first column, which is why the preprocessor
required # in the first column (ie, you didn't have to quote it in
that position).
--
Michael Meissner, Data General.
Uucp:		...!mcnc!rti!xyzzy!meissner		If compiles were much
Internet:	meissner@dg-rtp.DG.COM			faster, when would we
Old Internet:	meissner%dg-rtp.DG.COM@relay.cs.net	have time for netnews?

jon@jonlab.UUCP (Jon H. LaBadie) (10/02/89)

Sorry if I am treading old territory here.  My news feed was down for
a considerable time and I have just picked up this thread.

The compilers I have used, principally within the AT&T environment
have a vestigal error message relating to the back quote (`).

If one enters a character constant with the wrong quotes, eg. `a`
instead of 'a', the compiler complains about:

	Illegal BCD constant

I have tried numerous single and multi character combinations and
none were "legal BCD constansts".  I assume that BCD constants were
considered as a possible addition to the language at one time and
for whatever reason, rejected.

Does anyone have any insight into the history of this error message?

-- 
Jon LaBadie
{att, princeton, bcr}!jonlab!jon
{att, attmail, bcr}!auxnj!jon

zep@cbnewsj.ATT.COM (joel.ratsaby) (10/05/89)

I have a question regarding the fseek() function.
If I open a file for the first time (let's assume the fp is now the
file descriptor), then can I fseek(fp,(any positive offset), 0) ?

I am trying to design a simple hashing algorithm, and I need to be able
to place information on the file at specific places in the file.
On the first time (after opening the file) I want to be able to seek
forward to any location from the start. Should I first write nulls
to the file (inorder to establish the length of the file)
and only then call fseek(fp,(any offset less than the max length of file),fp) ?
thanks
j.e.r