llothar wrote On 03/15/07 04:25,:
I'm using SmallEiffel - which is more or less a huge preprocessor -
for C. It has the option to compile the whole Eiffel program into one
huge C file but doesn't add a static declaration to the functions.
I wonder if there are some clever optimizing compilers that do more
magic (for example inlining) of static functions.
It's not much time to patch the eiffel compiler, but if it is useless
there are other things to waste time.
The optimization may or may not be better, but at least
the information available to the optimizer is more complete
for a static function than for an externally-linked function.
If the optimizer can "see" all of the calls to the function,
it may be able to take actions that would not be possible if
the function could be called from unknown, separately-compiled
modules that may not even have been written yet.
The pre-Standard VAXC implementation took advantage of
the extra optimization opportunities for static functions.
Its <ctype.h> header contained static definitions of all the
isxxx() and toxxx() functions, not the more usual external
declarations plus masking macros. In the course of optimizing,
the compiler would simply discard any static functions that
weren't used. If you included <ctype.h> you'd get source code
for all the functions, but if you used only isdigit() there
would be no generated code for isalpha() and tolower() and
the rest. I think VAXC would also in-line sufficiently simple
static functions, like those of <ctype.h>, making the masking
macros unnecessary.
The technique had some odd consequences: for example, two
different modules could create function pointers aimed at
isalpha(), and the pointers would compare unequal. I do not
know whether that was a violation of the Standard -- but, as
I mentioned, VAXC was pre-Standard anyhow, and disagreed with
the Standard in other ways, too.