W dniu niedziela, 30 września 2012 03:30:06 UTC+2 użytkownik Stephen Sprunk napisał:
it is actually _less_ typing becouse you have changed names use
module_a instead a or I can rewrite my example with your names
module main;
C has no keyword "module"; are you proposing a new keyword? If so, that
would instantly break every program that uses the identifier "module"
for some other purpose, e.g. a function or variable name.
C has no keyword "reaches"; are you proposing a new keyword? If so,
that would instantly break every program that uses the identifier
"reaches" for some other purpose, e.g. a function or variable name.
Also, it is not clear what these lines mean because many implementations
allow ',' to be part of a file name. For instance, is it referring to a
single module named "a,b,c", two modules named "a,b" and "c", two
modules named "a" and "b,c", or three modules named "a", "b", and "c"?
For that matter, many implementations allow ';', CR and LF in file names
as well, so how does the compiler even know where the list of modules
ends? How does this change the language's grammar as a whole?
Furthermore, does this mean that the module names become identifiers and
are therefore unavailable for other uses? Or is there some sort of
scoping that you haven't explained?
Once you sort all these issues out, you'll end up realizing that what
you need is this:
reaches "a", "b", "c";
Of course, one could easily propose doing the same thing with #include
directives:
#include "a.h", "b.h", "c.h"
Note that the only difference in length now comes from the ".h"
suffixes, which are merely a convention, not something that the Standard
requires.
void main()
{
a init();
b init();
c init();
a run();
b run();
c run();
}
The only difference you are proposing here is "a init();" rather than
"a_init();", and I see no advantage to the former that outweighs the
fact that the latter has already worked just fine for ~40 years. It
saves no typing yet requires massive changes to the C grammar and
potentially breaks billions of lines of code that work just fine.
besides dat one do not have to type header file contents a.c external
linkage symbols are visible automaticaly;
How is the translator supposed to know that module "a" is defined in
"a.c"? Your use of "module main;" above indicates that the module name
might be different from the source file name minus the ".c" suffix.
Logically, some modules might consist of multiple source files.
What is the translator supposed to do if the source is not available for
a module that is referenced? Hint: the current system doesn't need the
source because it can use header files.
S