| GNU C did it decades ago (but of course the GNU project is laced with Lisp influence). In GNU C, if a braced compound statement is put into parentheses, it becomes an expression. The value of the last expression in the compound is implicitly returned: // c receives 5
int c = ({ int a = 2, b = 3; a + b; })
Never mind that; the standard C macro preprocessor has "implicit return": // not return #define max(x, y) return ((x) > ...
#define max(x, y) ((x) > (y) ? (x) : (y))
Note that the "implicit return" in Lisp is just from mathematics: f(x, y) = x^2 - y^2
Not: f(x, y) { return x^2 - y^2 }
the return keyword is kind of a disease/blemish, introduced by way of Blub programming languages."Implicit return" is like saying "face with implicit warts" in reference to a face that is perfectly smooth and never had a blemish. In functional languages, there is only one expression which makes up the body of a function and of course that expression's value is yielded; it's the definition of the function. Explicit return is a form of goto; it's required only in imperative programming, and even there we can leave it out for the last statement. The C preprocessor doesn't have a return operator because it's a functional, term rewriting language. Every definition has one replacement in which there are no side effects or goto. |