Jump to content

Function (programming)

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Miguel~enwiki (talk | contribs) at 21:48, 20 May 2002 (*Moved computerprogramming content from function). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

In programming, a function is a part of a program that can be called with certain arguments (or parameters) from inside the program or elsewhere, and returns a value. Although the term is related to the mathematical term it is less strict; a function may return different results each time, even if it is called with the same arguments, and a function may have side effects, that is, it may cause changes that remain after the call of the function has ended. Such functions can be mathematically modelled by incorporating a notion of time and global parameters. An exception to this difference is a function in pure functional programming that returns always the same result if called with the same arguments and has no side effects.

A procedure is similar to a function but has only side effects and does not return a value. In some programming languages, such as ANSI C, where there are only functions there is often a type such as void for the result of a function that has no result.