HOME

TheInfoList



OR:

In
computer science Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, a null function (or null operator) is a
subroutine In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed. Functions ma ...
that leaves the
program state In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions; the remembered information is called the state of the system. The set of states a system can oc ...
unchanged. When it is part of the
instruction set In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions described by that ISA, such as a central processing unit (CPU), is called a ...
of a processor, it is called a NOP or NOOP (No OPeration). Mathematically, a (computer) function f is null if and only if its execution leaves the program state s unchanged. That is, a null function is an
identity function Graph of the identity function on the real numbers In mathematics, an identity function, also called an identity relation, identity map or identity transformation, is a function that always returns the value that was used as its argument, unc ...
whose
domain Domain may refer to: Mathematics *Domain of a function, the set of input values for which the (total) function is defined ** Domain of definition of a partial function **Natural domain of a partial function **Domain of holomorphy of a function *Do ...
and
codomain In mathematics, the codomain or set of destination of a function is the set into which all of the output of the function is constrained to fall. It is the set in the notation . The term range is sometimes ambiguously used to refer to either ...
are both the
state space A state space is the set of all possible configurations of a system. It is a useful abstraction for reasoning about the behavior of a given system and is widely used in the fields of artificial intelligence and game theory. For instance, the t ...
S of the program, and for which: : f(s)=s for all elements s \in S. Less rigorous definitions may also be encountered. For example, a function may take a single operand, transform it into a new
data type In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
, and return the result.Example of a
type conversion In computer science, type conversion, type casting, type coercion, and type juggling are different ways of changing an expression from one data type to another. An example would be the conversion of an integer value into a floating point valu ...
function labeled as a "null function"
_NULLF - null function.
/ref> While such usages bear a strong visual resemblance to identity functions, they create or alter a binary data value and thus change the program state. From a software maintainability perspective it is better to identify such "minor" alternations of state explicitly, since calling them null functions provides future maintainers of the code with no insights on their actual purposes.


Uses

Null functions have several uses. During
software development Software development is the process of conceiving, specifying, designing, programming, documenting, testing, and bug fixing involved in creating and maintaining applications, frameworks, or other software components. Software development inv ...
, null functions with the same names and
type signature In computer science, a type signature or type annotation defines the inputs and outputs for a function, subroutine or method. A type signature includes the number, types, and order of the arguments contained by a function. A type signature is ty ...
s as a planned functions are often used as stubs—that is, as non-functional placeholders that allow the incomplete body of code to be compiled and tested prior to completion of all planned features. Null functions, particularly the NOP variety, are also used to provide delays of indeterminate length within wait loops. This is a common strategy in dedicated device controllers that must wait for an external input and have no other tasks to perform while they are waiting. Such wait loops are also used in
software applications Software is a set of computer programs and associated documentation and data. This is in contrast to hardware, from which the system is built and which actually performs the work. At the lowest programming level, executable code consists ...
on larger
multiprocessing Multiprocessing is the use of two or more central processing units (CPUs) within a single computer system. The term also refers to the ability of a system to support more than one processor or the ability to allocate tasks between them. There ar ...
computer systems. However, for multiprocessing systems a better approach is to use
operating system An operating system (OS) is system software that manages computer hardware, software resources, and provides common daemon (computing), services for computer programs. Time-sharing operating systems scheduler (computing), schedule tasks for ef ...
functions that let other processes use the
CPU A central processing unit (CPU), also called a central processor, main processor or just processor, is the electronic circuitry that executes instructions comprising a computer program. The CPU performs basic arithmetic, logic, controlling, an ...
during the waiting period. A third use of null functions is as the definition of a program feature that, if created inadvertently, is almost always deleterious. Unintended null functions can arise during the development of complex programs, and like
dead code The term dead code has multiple definitions. Some use the term to refer to code (i.e. instructions in memory) which can never be executed at run-time. In some areas of computer programming, dead code is a section in the source code of a program whic ...
, such occurrences indicate serious flaws in program structures. A null function or method is often used as the default behavior of a revectorable function or overrideable method in an object framework.


See also

* IEFBR14


References


External links

* Makes humorous statements about the NULL encryption algorithm. {{DEFAULTSORT:Null Function Subroutines