$ in identifiers -- poll

Steve Glaser steveg at hammer.UUCP
Fri Dec 7 08:30:29 AEST 1984


In article <260 at sftri.UUCP> jss at sftri.UUCP (J.S.Schwarz) writes:
>-- 
>
>> I'd like to bring up the matter of using '$' in C identifiers.  Here are
>> several points of view I've come across:
>> 
>> What does the standard say about this?  '$' is not used anywhere else in C.
>> I think its use as a letter should be officially permitted.  (It makes a
>> nice "package" identifier, c.f. VMS.)
> 
>The latest (Oct 31) ANSI draft that I have does not include '$' as
>a character in identifiers.  
>
>It should be pointed out that many preprocessors (such as YACC) use
>'$' in some way to distinguish "special" identifiers.  It would
>cause confusion if '$' was now made legal in ordinary C identifiers.
>
>Looking at my keyboard, the characters not currently used by C (outside
>of comments and strings) are '@', '$', and backquote(`).  If you really 
>need a new nonalphabetic character in identifiers I would suggest backquote.
>Identifiers like xyz`p look nice to me. (But personally, I see no
>need for such a modification to the language definition.)
>
>	Jerry Schwarz
>	ihnp4!btlunix!jss

Backquote is already used in the GCOS version of C.  Try this on you're
favorite C compiler (4.2 in this case, but it's in all versions of PCC
I've looked for it).

	% cat test2.c
	main()
	{
		char c[] = `hi there`;
	}
	% cc test2.c
	"test2.c", line 3: no automatic aggregate initialization
	"test2.c", line 3: BCD constant exceeds 6 characters
	"test2.c", line 3: gcos BCD constant illegal
	"test2.c", line 3: illegal left operand of assignment operator
	%

Seriously though, I can't see adding anymore letters to the C language
identifier set just "cause it'd be nice and besides VMS does it".  If
we have to change that area, let it be in the area of somehow allowing
the various national variants of the ISO character code (of which US
ASCII is just one).  That's the only character set issue that I can see
that's important enough to warrant changing the language for.
Unfortunately, with the overloading of characters ('|' is a letter in
some countries), I don't see an easy solution emerging.

	Steve Glaser
	steveg.tektronix at csnet-relay
	tektronix!steveg



More information about the Comp.lang.c mailing list