[comp.lang.c] Suggestion for a new C operator

amoss@batata.Huji.AC.IL (amos shapira) (01/15/90)

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@batata.bitnet
amoss@batata.huji.ac.il