Liste des Groupes | Revenir à cl c |
One programming language that has comma separators is Fortran,
by the way. Fortran persisted in providing this feature in spite of
shooting itself in the foot with ambiguities.
>
When Fortran was being designed, people were naive in writing
compilers. They thought that it would simplify things if they
removed all spaces from the code before lexically scanning it and
parsing.
>
Thus "DO I = 1, 10" becomes "DOI=1,10" and "FO I = 1, 10"
becomes "FOI=1,10"
>
After that you have to figure out that "DOI=1,10" is the
header of a DO loop which steps I from 1 to 10,
whereas "FOI=1,10" assigns 110 to variable FOI.
Commas are "fluff punctuators". They could be removed without
making a difference to the abstract syntax.
>
Fun fact: early Lisp (when it was called LISP) had commas
in lists. They were optional. (1, 2, 3) or (1 2 3). Your
choice.
>
Comma separation causes problems when arguments can be empty!
>
In C preprocessing MAC() is actually a macro with one argument,
which is empty. MAC(,) is a macro with two empty arguments
and so on. You cannot write a macro call with zero arguments.
>
Now, if macros didn't use commas, there wouldn't be a problem
at all: MAC() -> zero args; MAC(abc) -> one arg;
MAC(abc 2) -> two args.
Wow, consistency. And no dangling comma nonsense to deal with in
complex, variadic macros!
Les messages affichés proviennent d'usenet.