In programming languages, a separate named unit of code that performs a specific calculation or procedure. To use functions, they must be declared in a special area of the program set aside for this purpose. A function includes placeholders, called logical parameters, that will be replaced by real values (actual parameters) when the function is initiated through a call … [Read more...] about Function
Technipages Explains Function
A function in a body of code is an identified smaller piece of code whose position is dependent on the larger body of code. It has a defined role to perform a single specific task. Once a function is written at a point in a program, it is accessible from any part of that same program.
Functions are mainly used because they can be re-used hence save time, functions once they have been declared can be used in as many as possible places and times. Most functions being used, once they have been declared can also be used by other programmers in several different programs. A programmer can compile a list of functions and export them to be used in other programs.
Functions in programming can be traced to the Lambda Calculus system which was developed in the 1930s. Lambda Calculus allows for the provision of a base for evaluating functions and their results. Programming languages that use the Lambda Calculus model are Common Lisp, Scheme, Clojure, Wolfram Language, Racket, and Haskell. Functions in programming are also being utilized by some other programming languages to create a sub-hub in the programming niche for themselves, and examples are XML, SQL, and Lex/Yacc.
Common Uses of Function
- The main reason a function can be used is that it can be used to avoid repetition of commands within the program
- Functions and procedures are very similar when functions are initiated, and they return a value, procedures do not.
- Another reason a function can be used is to help define a logical structure for your program by breaking it into several smaller modules with apparent purposes.
Common Misuses of Function
- A function even though it’s a defined piece of code in a much more bigger body of code does not depend on the bigger code
- Re-usability of a function is highly doubtful as programs do not compile a list of well-known functions.