Opentopia Directory Encyclopedia Tools

Return statement

Encyclopedia : R : RE : RET : Return statement


In computer programming, the use of the 'return' keyword resumes execution at the point of the last call by reference to the top of the process' stack. Functions however can return a value to the code that called the function.

In C++, return exp; (where exp is an expression) is a statement of code which tells a function to return the execution, of the program, to the calling function, and report the value of exp. If the function does not have a return type (returns void), the return command can be used without a value to just break out of the current function and return to the calling one, as is the case in most versions of BASIC.

Certain programming languages, such as Perl and Ruby allow the programmer to omit an explicit return statement, specifying instead that the last evaluated expression is the return value of the subroutine. Values returned by the program when it terminates are often captured by Batch Programs.

Syntax

Return statements come in many shapes. The following syntaxes are most common:

As used in Java, C#, C, C++, and PHP:

return value;
As used in Smalltalk:

^ value
As used in Lisp:

(return value)
As used in BASIC:

RETURN

 


From Wikipedia, the Free Encyclopedia. Original article here. Support Wikipedia by contributing or donating.
All text is available under the terms of the GNU Free Documentation License See Wikipedia Copyrights for details.

Search Titles
0123456789
ABCDEFGHIJ
KLMNOPQRST
UVWXYZ?

E-mail this article to:

Personal Message: