Function (computer programming): Difference between revisions

Content deleted Content added
a function can call itself (not just other software); reuse of 'unit' does not add value; interface (syntax) is important as behavior (semantics)
to avoid confusing the reader, describe why this article covers multiple terms
Line 16:
 
Callable units are present at multiple levels of [[abstraction]] in the programming environment. For example, a [[programmer]] may write a function in [[source code]] that is compiled to machine code that implements similar [[semantics]]. There is a callable unit in the source code and an associated one in the machine code, but they are different kinds of callable units {{endash}} with different implications and features.
 
==Terminology==
 
The meaning of each term callable term, function, subprogram, procedure, method, routine and subroutine, is, in fact different. They are not [[synonymous]]. None-the-less, they each add a capability to programming that has commonality.
 
The term used tends to reflect the context in which it is used {{endash}} usually based on the language being used. For exmaple:
 
* ''Subprogram'' was used long ago but today is antiquated
 
* Some consider ''function'' to imply mathematical function; no side-effects, but in many contexts (languages) ''function'' does not imply that
 
* In the context of [[Visual Basic]], {{code|Sub}}, short for ''subroutine'' or ''subprocedure'', is the name of a callable that does not return a value whereas a {{code|Function}} does return a value
 
* [[C (programming language)|C]] and [[C++]] have ''functions'', but related languages [[C#]] and [[Java (programming language)|Java]] use the word ''method'' for what is essentially a function that is a member of an [[Object (computer science)|object]]
 
==History==