Re: $ & _



antianti@xxxxxxxxxxxxxx said:

Hi folks,

When in the history of C did it become acceptable to use $
in a variable or function name?

As far as I know, it's never been legal to do that in a C program. If you
do so, implementations are free to reject your program. Conversely, they
are free to accept it - this is one of those situations where an
implementation can extend the language, at the expense of portability to
implementations that haven't extended it in that direction with that
syntax. I guess that you have encountered such an extension.

Why do some people say that it is a bad idea to begin
a variable name with an underscore?

In certain circumstances (and by no means obscure or unlikely
circumstances), the Standard reserves identifiers beginning with an
underscore for exclusive use by the implementation. The idea is to reduce
the likelihood of a conflict between the implementation's identifiers and
your own. If you go around _starting _identifiers _with _underscores _all
_over _the _place, you are increasing that likelihood. So it's a bad idea,
so don't do it.

Is it bad form to have a variable or function that is a
single $ or _ ?

It depends on whether you are composing an entry for the IOCCC.

--
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
.



Relevant Pages