Register functions ?

Kevin Martin kpmartin at watmath.UUCP
Mon Sep 3 05:42:00 AEST 1984

>	As long as I'm twiddling the semantics of the language, I'd like to
>	propose "register" functions like these:
>		static register int func (arg, arg2) {...}
>		static register void func ....
>	The purpose of the "register" (even for void !) is to prevent the
>	programmer from taking the address of the function.
>			teltone!warren
I have had some thoughts about 'register' too. I see it as being a storage
class modifier which tells the compiler that the value will not be changed in
any 'sneaky' manner.
If you think about it, this is its current meaning.

For extern's, it becomes a promise that the named variable will not be changed
by any functions I call.
For functions it means it returns the same value if called with the
same args, and has no side effects.

One problem with this extension is that the compiler cannot enforce
your promises in the same manner as it prevents sneak access to auto
register variables (by preventing you from &'ing them).
The other problem is due to interpreting 'register' as part of the
storage class... What if I want a pointer to a "register function"?
There is no syntax that fits... The only possible syntax is already used up
by "register pointer" to "regular function"...

                               Kevin Martin, UofW Software Development Group

More information about the Comp.lang.c mailing list