| Liste des Groupes | Revenir à cl c |
David Brown <david.brown@hesbynett.no> writes:Right.
[...]"42" is an expression of type "int", and so is 'printf("Hello\n")'.[...]
How (and why) would a language distinguish between them and allow one
but not the other?
Ada, Pascal, and similar languages do exactly this, for what many
people consider to be good reasons.
In both languages, functions and procedures are distinct. FunctionsErm, I hope that above printf() call does not create an error, but
return values; procedures do not. An expression cannot be turned
into a statement just by adding a semicolon. A function call is
an expression. A procedure call is a statement, not an expression.
An assignment is a statement, not an expression.
For I/O, the equivalent of printf is a procedure. In C,
printf("Hello, world\n") returns a negative result to denote an
error (and that value is often ignored).
[...]
Les messages affichés proviennent d'usenet.