Out of curiosity, why would you want one? Various conventions have been used by different programming-language families for specifying a function's return value. (The concept of "return value" is pretty widespread, though there are exceptions, such as stack-oriented languages like Forth, function-oriented ones like APL, and various esoteric languages.) Languages in the ALGOL family, such as ALGOL itself, Pascal, and Modula-2, return a value by assigning to the name of the function. In ALGOL 60: real procedure A(k); integer k; begin A := k + 1; end; In COBOL, you have the luxury or additional labor, depending on how you see it, of picking a different name for the return value, and assigning to that instead. Some COBOL dialects (including some of the dialects supported by MF COBOL for native code, but not managed code) let you use GOBACK RETURNING to return from a (sub)program. Fortran currently lets you use a COBOL-like method, with the result() clause to name the return variable; but it also permits ALGOL-style assignment to the function name. FORTRAN 77, which introduced the result() clause, also added a RETURN statement similar to the one in the C language family; but FORTRAN's RETURN can only be used from subroutines (not functions) and can only return integer values. Fortran 90 made RETURN (with a value) obsolescent. In the LISP-like languages, every expression evaluates to something, so there is no explicit return mechanism. This is generally true of functional languages; in the ML family the return value of a function is also the value of the final expression in the function body (which may be a tuple rather than a single value), but since ML languages automatically curry, the return "value" is often in fact another function. BASIC (the real language, not various almost-but-not-quite-exactly-unlike-BASICs such as VB) didn't let you return anything at all. You had to use global variables for everything. The "return" keyword as the generic mechanism for specifying a function's value is really peculiar to the C family. C's ancestor BCPL used the keyword RESULTIS, which was a contraction of its ancestor CPL's key-phrase RESULT IS. (I don't know what C's immediate ancestor language B, a simplified BCPL, used.) The C language family is large and widely used, but its conventions are certainly not universal.
↧