Something to use '$' for
David Herron, NPR Lover
david at ukma.UUCP
Wed Dec 12 06:41:32 AEST 1984
I know! We are wanting something that says "comment till end of line"
but all the suggestions so far go down in flames because that character
is already in use. Is '$' really not used? Could '$$' be used
to signal this type of comment? Does anybody really care?
At any rate. (---Pull out random piece of C code---) Here is a
C routine I wrote a long time ago. It used "regular" type comments
of course. I just redid the comments for illustration purposes.
------------------>Start C (with funny comments) routine<----------------
$$ putvc.c -- Contains ctovc routine. Generates readable control characters.
$$
$$ char *ctovc(c) char c;
$$ Pass a character in c. The routine returns a string representing the
$$ character. If the character is a non-printing character, it generates
$$ the backslash-mnemonic equivalent, otherwise it returns the character.
$$
char bf[6]; $$ to put \nnn in
char *ctovc(c)
char c;
{
switch(c)
{
case '\n': return("\\n"); $$ newline
case '\t': return("\\t"); $$ tab
case '\b': return("\\b"); $$ backspace
case '\r': return("\\r"); $$ return
case '\f': return("\\f"); $$ formfeed
case '\\': return("\\\\"); $$ backslash
case '\'': return("\'"); $$ single-quote
default:
if(c>=' ' && c<0200)
sprintf(bf,"%c",c);
else
sprintf(bf,"\\%o",(int)c);
return(bf);
}
}
------------------------>End C Routine<----------------------------
# could be used if people want to let *non-standard* C compilers live.
Actually, the '$' is needed in some environments...... The purpose of C
is to support system programmers. System programmers have to interface
to the existing system. If the existing system uses symbols containing
the '$' character then C needs to support them in that environment or
the system programmer wont be able to call the standard system calls
in the way s/he is accustomed to doing.
Then there are systems where # is useful. (.....sigh....where does it stop)
(One example is the dec-10. Macro-10 uses # at the end of certain
symbols to tell the assembler that it needs to allocate space for it,
and ## means that the symbol is external. Then the IBM PL/1-F compiler
I used a few years ago accepted # as part of a symbol name, so assumably
the linker takes # in a symbol.) (Are there any systems where @
couldn't be used?) (How about '`'? (grave character)).
I'm going to stop before y'all get mad about all this rambling.......
-----------------------------------------
David Herron; ARPA-> "ukma!david"@ANL-MCS (Note the quote marks.)
UUCP-> unmvax -----------\
UUCP-> research ----------\_______ {anlams,anl-mcs} --\
UUCP-> boulder -----------/ >-!ukma!david
UUCP-> decvax!ucbvax ----/ cbosgd!hasmed!qusavx --/
(The usual warning about having no opinions). "I read banned books."
More information about the Comp.lang.c
mailing list