ndiamond@watdaisy.UUCP (Norman Diamond) (02/16/85)
Here is a suggestion that is only moderately ugly, but unambiguous and
won't break any programs.
(1) To refer to an external name (data or function) whose name isn't
a valid C identifier:
extern "external$name" [maybe a type] c_identifier [maybe ()]
(The external name is in a quoted string. The brackets are meta-syntax
to indicate optional tokens.)
For that matter, the external name could also be a valid c identifier,
but old or ported code still wants to use the old name. Anyway, the
external name would not be available to the source code; it would have
to use the C identifier. However, the compiler would generate object
code using the external name.
(2) To define some data or a function with an external name that isn't
a valid C identifer:
"external$name" [maybe a type] c_identifer [maybe () or initializer, etc.]
Same criteria as for the first suggestion. This one's a little harder on
a parser, because the string might look like the beginning of an expression
instead of a declaration. However, it really isn't ambiguous, and it is
surrounded by semicolons (unless it's the first declaration).
The second suggestion is only of interest to anyone who wants C stuff to
be callable from other languages. Admitted, fewer C programmers would
accept this kind of requirement, than for their own need to issue system
calls and such stuff in non-unix environments :-) .
--
Norman Diamond
UUCP: {decvax|utzoo|ihnp4|allegra|clyde}!watmath!watdaisy!ndiamond
CSNET: ndiamond%watdaisy@waterloo.csnet
ARPA: ndiamond%watdaisy%waterloo.csnet@csnet-relay.arpa
"Opinions are those of the keyboard, and do not reflect on me or higher-ups."jeff@alberta.UUCP (C. J. Sampson) (02/23/85)
The problem: Someone may have to write a program to call a routine called "*SYS$CALL" under a non-UNIX operating system. '$' is not a valid character in a variable or function name. Proposed solution: Modify the C standard to allow '$' in variable and function names. This has been objected to extensively. Perhaps we could do this in the linker. If people have strong objections to changing the C compiler, a linker option could be implemented that would make, say "_syscall" and "*SYS$CALL", or whatever, the same thing. Another alternatave, which saves re-writing either the compiler or the linker, and that people on systems without source could do, would be to write a little program that would massage the object file and change all refrences of "_syscall" to "*SYS$CALL". Any comments on this idea? ===================================================================== Curt Sampson ihnp4!alberta!jeff --------------------------------------------------------------------- "It looked like something resembling white marble, which was probably what is was: something resembling white marble."