Suggestion for a new C operator
amos shapira
amoss at batata.Huji.AC.IL
Mon Jan 15 05:28:15 AEST 1990
Hello,
There is a new operator I though that might be usefull in making
C programs more readable and easy to modify, I call it typeof(var).
For instance, in casting function's returned address, or if we want
to declare one variable to have the type of another one, it whould be
easier to write and modify code writen like this:
struct stat *stp;
stp = (typeof(stp))malloc(sizeof(*stp));
or
typeof(stp) newvar;
It should also make macros more portable and global.
I think that there should be no big problem impelmenting this since
the compiler should allready have for each variable it's type, so it
(the compiler) only have to treat this operator as a type-specifier,
it could even be impelemented in a specialized pre-processor.
Well, what do you think of it?
Bye Bye,
- Amos Shapira
amoss at batata.bitnet
amoss at batata.huji.ac.il
More information about the Comp.lang.c
mailing list